@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <div class="uix-field-wrapper"> |
| 2 | 2 | <ul class="ui-tab-nav"> |
| 3 | - <?php if ( class_exists( 'LSX_Currencies' ) ) { ?> |
|
| 4 | - <li><a href="#ui-currencies" class="active"><?php esc_html_e( 'Currencies', 'lsx-currencies' ); ?></a></li> |
|
| 3 | + <?php if (class_exists('LSX_Currencies')) { ?> |
|
| 4 | + <li><a href="#ui-currencies" class="active"><?php esc_html_e('Currencies', 'lsx-currencies'); ?></a></li> |
|
| 5 | 5 | <?php } ?> |
| 6 | 6 | </ul> |
| 7 | 7 | |
| 8 | - <?php if ( class_exists( 'LSX_Currencies' ) ) { ?> |
|
| 8 | + <?php if (class_exists('LSX_Currencies')) { ?> |
|
| 9 | 9 | <div id="ui-currencies" class="ui-tab active"> |
| 10 | 10 | <table class="form-table"> |
| 11 | 11 | <tbody> |
| 12 | - <?php do_action( 'lsx_framework_dashboard_tab_content', 'currency_switcher' ); ?> |
|
| 12 | + <?php do_action('lsx_framework_dashboard_tab_content', 'currency_switcher'); ?> |
|
| 13 | 13 | </tbody> |
| 14 | 14 | </table> |
| 15 | 15 | </div> |
| 16 | 16 | <?php } ?> |
| 17 | 17 | |
| 18 | - <?php do_action( 'lsx_framework_dashboard_tab_bottom', 'general' ); ?> |
|
| 18 | + <?php do_action('lsx_framework_dashboard_tab_bottom', 'general'); ?> |
|
| 19 | 19 | </div> |
@@ -16,24 +16,24 @@ discard block |
||
| 16 | 16 | * @return void |
| 17 | 17 | */ |
| 18 | 18 | function lsx_currencies_get_price_html( $value = '' ) { |
| 19 | - $prefix = '<span class="amount lsx-currencies" '; |
|
| 20 | - $value = preg_replace( '/[^0-9.]+/', '', $value ); |
|
| 21 | - $decimals = substr_count( $value, '.' ); |
|
| 19 | + $prefix = '<span class="amount lsx-currencies" '; |
|
| 20 | + $value = preg_replace( '/[^0-9.]+/', '', $value ); |
|
| 21 | + $decimals = substr_count( $value, '.' ); |
|
| 22 | 22 | |
| 23 | - if ( false !== $decimals && $decimals > 1 ) { |
|
| 24 | - $decimals--; |
|
| 25 | - $decimals = (int) $decimals; |
|
| 26 | - $value = preg_replace( '/' . preg_quote( '.', '/' ) . '/', '', $value, $decimals ); |
|
| 27 | - } |
|
| 28 | - $prefix .= '>'; |
|
| 29 | - $suffix = '</span>'; |
|
| 30 | - setlocale( LC_MONETARY, 'en_US' ); |
|
| 23 | + if ( false !== $decimals && $decimals > 1 ) { |
|
| 24 | + $decimals--; |
|
| 25 | + $decimals = (int) $decimals; |
|
| 26 | + $value = preg_replace( '/' . preg_quote( '.', '/' ) . '/', '', $value, $decimals ); |
|
| 27 | + } |
|
| 28 | + $prefix .= '>'; |
|
| 29 | + $suffix = '</span>'; |
|
| 30 | + setlocale( LC_MONETARY, 'en_US' ); |
|
| 31 | 31 | |
| 32 | - // Work out the other tags |
|
| 33 | - $currency = '<span class="currency-icon ' . mb_strtolower( lsx_currencies()->base_currency ) . '">' . lsx_currencies()->base_currency . '</span>'; |
|
| 34 | - $amount = '<span class="value" data-price-' . lsx_currencies()->base_currency . '="' . trim( str_replace( 'USD', '', money_format( '%i', ltrim( rtrim( $value ) ) ) ) ) . '">' . str_replace( 'USD', '', money_format( '%i', ltrim( rtrim( $value ) ) ) ) . '</span>'; |
|
| 35 | - $price_html = '<span class="amount lsx-currencies">' . $currency . $amount . '</span>'; |
|
| 36 | - return $price_html; |
|
| 32 | + // Work out the other tags |
|
| 33 | + $currency = '<span class="currency-icon ' . mb_strtolower( lsx_currencies()->base_currency ) . '">' . lsx_currencies()->base_currency . '</span>'; |
|
| 34 | + $amount = '<span class="value" data-price-' . lsx_currencies()->base_currency . '="' . trim( str_replace( 'USD', '', money_format( '%i', ltrim( rtrim( $value ) ) ) ) ) . '">' . str_replace( 'USD', '', money_format( '%i', ltrim( rtrim( $value ) ) ) ) . '</span>'; |
|
| 35 | + $price_html = '<span class="amount lsx-currencies">' . $currency . $amount . '</span>'; |
|
| 36 | + return $price_html; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | 45 | function lsx_currency_value( $atts ) { |
| 46 | - $a = shortcode_atts( |
|
| 47 | - array( |
|
| 48 | - 'value' => '0.00', |
|
| 49 | - ), |
|
| 50 | - $atts |
|
| 51 | - ); |
|
| 52 | - return lsx_currencies_get_price_html( $a['value'] ); |
|
| 46 | + $a = shortcode_atts( |
|
| 47 | + array( |
|
| 48 | + 'value' => '0.00', |
|
| 49 | + ), |
|
| 50 | + $atts |
|
| 51 | + ); |
|
| 52 | + return lsx_currencies_get_price_html( $a['value'] ); |
|
| 53 | 53 | } |
| 54 | 54 | add_shortcode( 'lsx_currency_value', 'lsx_currency_value' ); |
@@ -15,24 +15,24 @@ discard block |
||
| 15 | 15 | * @param string $value |
| 16 | 16 | * @return void |
| 17 | 17 | */ |
| 18 | -function lsx_currencies_get_price_html( $value = '' ) { |
|
| 18 | +function lsx_currencies_get_price_html($value = '') { |
|
| 19 | 19 | $prefix = '<span class="amount lsx-currencies" '; |
| 20 | - $value = preg_replace( '/[^0-9.]+/', '', $value ); |
|
| 21 | - $decimals = substr_count( $value, '.' ); |
|
| 20 | + $value = preg_replace('/[^0-9.]+/', '', $value); |
|
| 21 | + $decimals = substr_count($value, '.'); |
|
| 22 | 22 | |
| 23 | - if ( false !== $decimals && $decimals > 1 ) { |
|
| 23 | + if (false !== $decimals && $decimals > 1) { |
|
| 24 | 24 | $decimals--; |
| 25 | 25 | $decimals = (int) $decimals; |
| 26 | - $value = preg_replace( '/' . preg_quote( '.', '/' ) . '/', '', $value, $decimals ); |
|
| 26 | + $value = preg_replace('/'.preg_quote('.', '/').'/', '', $value, $decimals); |
|
| 27 | 27 | } |
| 28 | 28 | $prefix .= '>'; |
| 29 | 29 | $suffix = '</span>'; |
| 30 | - setlocale( LC_MONETARY, 'en_US' ); |
|
| 30 | + setlocale(LC_MONETARY, 'en_US'); |
|
| 31 | 31 | |
| 32 | 32 | // Work out the other tags |
| 33 | - $currency = '<span class="currency-icon ' . mb_strtolower( lsx_currencies()->base_currency ) . '">' . lsx_currencies()->base_currency . '</span>'; |
|
| 34 | - $amount = '<span class="value" data-price-' . lsx_currencies()->base_currency . '="' . trim( str_replace( 'USD', '', money_format( '%i', ltrim( rtrim( $value ) ) ) ) ) . '">' . str_replace( 'USD', '', money_format( '%i', ltrim( rtrim( $value ) ) ) ) . '</span>'; |
|
| 35 | - $price_html = '<span class="amount lsx-currencies">' . $currency . $amount . '</span>'; |
|
| 33 | + $currency = '<span class="currency-icon '.mb_strtolower(lsx_currencies()->base_currency).'">'.lsx_currencies()->base_currency.'</span>'; |
|
| 34 | + $amount = '<span class="value" data-price-'.lsx_currencies()->base_currency.'="'.trim(str_replace('USD', '', money_format('%i', ltrim(rtrim($value))))).'">'.str_replace('USD', '', money_format('%i', ltrim(rtrim($value)))).'</span>'; |
|
| 35 | + $price_html = '<span class="amount lsx-currencies">'.$currency.$amount.'</span>'; |
|
| 36 | 36 | return $price_html; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | * @param array $atts |
| 43 | 43 | * @return void |
| 44 | 44 | */ |
| 45 | -function lsx_currency_value( $atts ) { |
|
| 45 | +function lsx_currency_value($atts) { |
|
| 46 | 46 | $a = shortcode_atts( |
| 47 | 47 | array( |
| 48 | 48 | 'value' => '0.00', |
| 49 | 49 | ), |
| 50 | 50 | $atts |
| 51 | 51 | ); |
| 52 | - return lsx_currencies_get_price_html( $a['value'] ); |
|
| 52 | + return lsx_currencies_get_price_html($a['value']); |
|
| 53 | 53 | } |
| 54 | -add_shortcode( 'lsx_currency_value', 'lsx_currency_value' ); |
|
| 54 | +add_shortcode('lsx_currency_value', 'lsx_currency_value'); |
|
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | // If this file is called directly, abort. |
| 16 | 16 | if ( ! defined( 'WPINC' ) ) { |
| 17 | - die; |
|
| 17 | + die; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | define( 'LSX_CURRENCIES_PATH', plugin_dir_path( __FILE__ ) ); |
@@ -31,6 +31,6 @@ discard block |
||
| 31 | 31 | * @return object \lsx\currencies\classes\Currencies() |
| 32 | 32 | */ |
| 33 | 33 | function lsx_currencies() { |
| 34 | - return \lsx\currencies\classes\Currencies::init(); |
|
| 34 | + return \lsx\currencies\classes\Currencies::init(); |
|
| 35 | 35 | } |
| 36 | 36 | lsx_currencies(); |
@@ -13,17 +13,17 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // If this file is called directly, abort. |
| 16 | -if ( ! defined( 'WPINC' ) ) { |
|
| 16 | +if (!defined('WPINC')) { |
|
| 17 | 17 | die; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -define( 'LSX_CURRENCIES_PATH', plugin_dir_path( __FILE__ ) ); |
|
| 21 | -define( 'LSX_CURRENCIES_CORE', __FILE__ ); |
|
| 22 | -define( 'LSX_CURRENCIES_URL', plugin_dir_url( __FILE__ ) ); |
|
| 23 | -define( 'LSX_CURRENCIES_VER', '1.2.3' ); |
|
| 20 | +define('LSX_CURRENCIES_PATH', plugin_dir_path(__FILE__)); |
|
| 21 | +define('LSX_CURRENCIES_CORE', __FILE__); |
|
| 22 | +define('LSX_CURRENCIES_URL', plugin_dir_url(__FILE__)); |
|
| 23 | +define('LSX_CURRENCIES_VER', '1.2.3'); |
|
| 24 | 24 | |
| 25 | -require_once LSX_CURRENCIES_PATH . 'classes/deprecated/class-lsx-currencies.php'; |
|
| 26 | -require_once LSX_CURRENCIES_PATH . 'classes/class-currencies.php'; |
|
| 25 | +require_once LSX_CURRENCIES_PATH.'classes/deprecated/class-lsx-currencies.php'; |
|
| 26 | +require_once LSX_CURRENCIES_PATH.'classes/class-currencies.php'; |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Returns the main instance of the class |
@@ -14,37 +14,37 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class LSX_Currencies { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * A wrapper for the deprecated class. |
|
| 19 | - * |
|
| 20 | - * @var object |
|
| 21 | - */ |
|
| 22 | - public $class = ''; |
|
| 17 | + /** |
|
| 18 | + * A wrapper for the deprecated class. |
|
| 19 | + * |
|
| 20 | + * @var object |
|
| 21 | + */ |
|
| 22 | + public $class = ''; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Holds instance of the class |
|
| 26 | - * |
|
| 27 | - * @var object \lsx\currencies\classes\Currencies() |
|
| 28 | - */ |
|
| 29 | - private static $instance; |
|
| 24 | + /** |
|
| 25 | + * Holds instance of the class |
|
| 26 | + * |
|
| 27 | + * @var object \lsx\currencies\classes\Currencies() |
|
| 28 | + */ |
|
| 29 | + private static $instance; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Constructor |
|
| 33 | - */ |
|
| 34 | - public function __construct() { |
|
| 35 | - $this->class = lsx_currencies(); |
|
| 36 | - } |
|
| 31 | + /** |
|
| 32 | + * Constructor |
|
| 33 | + */ |
|
| 34 | + public function __construct() { |
|
| 35 | + $this->class = lsx_currencies(); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Return an instance of this class. |
|
| 40 | - * |
|
| 41 | - * @return object |
|
| 42 | - */ |
|
| 43 | - public static function init() { |
|
| 44 | - // If the single instance hasn't been set, set it now. |
|
| 45 | - if ( ! isset( self::$instance ) ) { |
|
| 46 | - self::$instance = new self(); |
|
| 47 | - } |
|
| 48 | - return self::$instance; |
|
| 49 | - } |
|
| 38 | + /** |
|
| 39 | + * Return an instance of this class. |
|
| 40 | + * |
|
| 41 | + * @return object |
|
| 42 | + */ |
|
| 43 | + public static function init() { |
|
| 44 | + // If the single instance hasn't been set, set it now. |
|
| 45 | + if ( ! isset( self::$instance ) ) { |
|
| 46 | + self::$instance = new self(); |
|
| 47 | + } |
|
| 48 | + return self::$instance; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public static function init() { |
| 44 | 44 | // If the single instance hasn't been set, set it now. |
| 45 | - if ( ! isset( self::$instance ) ) { |
|
| 45 | + if (!isset(self::$instance)) { |
|
| 46 | 46 | self::$instance = new self(); |
| 47 | 47 | } |
| 48 | 48 | return self::$instance; |
@@ -16,560 +16,560 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Currencies { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Holds instance of the class |
|
| 21 | - * |
|
| 22 | - * @var object \lsx\currencies\classes\Currencies() |
|
| 23 | - */ |
|
| 24 | - private static $instance; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Holds the admin instance |
|
| 28 | - * |
|
| 29 | - * @var object \lsx\currencies\classes\Admin() |
|
| 30 | - */ |
|
| 31 | - public $admin; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Holds the frontend instance |
|
| 35 | - * |
|
| 36 | - * @var object \lsx\currencies\classes\Frontedn() |
|
| 37 | - */ |
|
| 38 | - public $frontend; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Holds the woocommerce instance |
|
| 42 | - * |
|
| 43 | - * @var object \lsx\currencies\classes\WooCommerce() |
|
| 44 | - */ |
|
| 45 | - public $woocommerce; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Holds the FacetWP instance |
|
| 49 | - * |
|
| 50 | - * @var object \lsx\currencies\classes\FacetWP() |
|
| 51 | - */ |
|
| 52 | - public $facetwp; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * This hold the URL, it defaults to the free exchange rates. |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - public $api_url = 'https://api.exchangeratesapi.io/latest?base=USD'; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * General Parameters |
|
| 63 | - */ |
|
| 64 | - /** @var string */ |
|
| 65 | - public $plugin_slug = 'lsx-currencies'; |
|
| 66 | - |
|
| 67 | - /** @var array */ |
|
| 68 | - public $options = false; |
|
| 69 | - |
|
| 70 | - /** @var string */ |
|
| 71 | - public $base_currency = 'USD'; |
|
| 72 | - |
|
| 73 | - /** @var array */ |
|
| 74 | - public $additional_currencies = array(); |
|
| 75 | - |
|
| 76 | - /** @var array */ |
|
| 77 | - public $available_currencies = array(); |
|
| 78 | - |
|
| 79 | - /** @var array */ |
|
| 80 | - public $flag_relations = array(); |
|
| 81 | - |
|
| 82 | - /** @var array */ |
|
| 83 | - public $currency_symbols = array(); |
|
| 84 | - |
|
| 85 | - /** @var boolean */ |
|
| 86 | - public $multi_prices = false; |
|
| 87 | - |
|
| 88 | - /** @var boolean */ |
|
| 89 | - public $convert_to_single = false; |
|
| 90 | - |
|
| 91 | - /** @var boolean */ |
|
| 92 | - public $app_id = false; |
|
| 93 | - |
|
| 94 | - /* Currency Switcher Options */ |
|
| 95 | - /** @var array */ |
|
| 96 | - public $menus = false; |
|
| 97 | - |
|
| 98 | - /** @var boolean */ |
|
| 99 | - public $display_flags = false; |
|
| 100 | - |
|
| 101 | - /** @var string */ |
|
| 102 | - public $flag_position = 'left'; |
|
| 103 | - |
|
| 104 | - /** @var string */ |
|
| 105 | - public $switcher_symbol_position = 'right'; |
|
| 106 | - |
|
| 107 | - /** @var boolean */ |
|
| 108 | - public $remove_decimals = false; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Constructor |
|
| 112 | - */ |
|
| 113 | - public function __construct() { |
|
| 114 | - add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); |
|
| 115 | - add_action( 'plugins_loaded', array( $this, 'set_defaults' ) ); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Return an instance of this class. |
|
| 120 | - * |
|
| 121 | - * @return object |
|
| 122 | - */ |
|
| 123 | - public static function init() { |
|
| 124 | - // If the single instance hasn't been set, set it now. |
|
| 125 | - if ( ! isset( self::$instance ) ) { |
|
| 126 | - self::$instance = new self(); |
|
| 127 | - } |
|
| 128 | - return self::$instance; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * After active plugins and pluggable functions are loaded |
|
| 133 | - */ |
|
| 134 | - public function plugins_loaded() { |
|
| 135 | - require_once LSX_CURRENCIES_PATH . 'classes/class-admin.php'; |
|
| 136 | - $this->admin = \lsx\currencies\classes\Admin::init(); |
|
| 137 | - |
|
| 138 | - require_once LSX_CURRENCIES_PATH . 'classes/class-frontend.php'; |
|
| 139 | - $this->frontend = \lsx\currencies\classes\Frontend::init(); |
|
| 140 | - |
|
| 141 | - if ( class_exists( 'WooCommerce' ) ) { |
|
| 142 | - require_once LSX_CURRENCIES_PATH . 'classes/class-woocommerce.php'; |
|
| 143 | - $this->woocommerce = \lsx\currencies\classes\WooCommerce::init(); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - if ( class_exists( 'FacetWP' ) ) { |
|
| 147 | - require_once LSX_CURRENCIES_PATH . 'classes/class-facetwp.php'; |
|
| 148 | - $this->facetwp = \lsx\currencies\classes\FacetWP::init(); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - require_once LSX_CURRENCIES_PATH . '/includes/template-tags.php'; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Get the options |
|
| 156 | - */ |
|
| 157 | - public function set_defaults() { |
|
| 158 | - $settings_tab = 'display'; |
|
| 159 | - if ( function_exists( 'tour_operator' ) ) { |
|
| 160 | - $options = get_option( '_lsx-to_settings', false ); |
|
| 161 | - $settings_tab = 'general'; |
|
| 162 | - } else { |
|
| 163 | - $options = get_option( '_lsx_settings', false ); |
|
| 164 | - |
|
| 165 | - if ( false === $options ) { |
|
| 166 | - $options = get_option( '_lsx_lsx-settings', false ); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - if ( false !== $options ) { |
|
| 171 | - $this->options = $options; |
|
| 172 | - $this->migration_uix_to_customize(); |
|
| 173 | - |
|
| 174 | - if ( isset( $this->options[ $settings_tab ] ) && isset( $this->options[ $settings_tab ]['currency'] ) ) { |
|
| 175 | - $this->base_currency = apply_filters( 'lsx_currencies_base_currency', $this->options[ $settings_tab ]['currency'], $this ); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - if ( isset( $this->options[ $settings_tab ]['additional_currencies'] ) && is_array( $this->options[ $settings_tab ]['additional_currencies'] ) && ! empty( $this->options[ $settings_tab ]['additional_currencies'] ) ) { |
|
| 179 | - $this->additional_currencies = $this->options[ $settings_tab ]['additional_currencies']; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - if ( isset( $this->options[ $settings_tab ]['multi_price'] ) && 'on' === $this->options[ $settings_tab ]['multi_price'] ) { |
|
| 183 | - $this->multi_prices = true; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - if ( isset( $this->options[ $settings_tab ]['convert_to_single_currency'] ) && 'on' === $this->options[ $settings_tab ]['convert_to_single_currency'] ) { |
|
| 187 | - $this->convert_to_single = true; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - if ( isset( $this->options[ $settings_tab ]['remove_decimals'] ) && 'on' === $this->options[ $settings_tab ]['remove_decimals'] ) { |
|
| 191 | - $this->remove_decimals = true; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if ( isset( $this->options['api']['openexchange_api'] ) && '' !== $this->options['api']['openexchange_api'] ) { |
|
| 195 | - $this->app_id = $this->options['api']['openexchange_api']; |
|
| 196 | - $this->api_url = 'http://openexchangerates.org/api/latest.json?app_id=' . $this->app_id; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - // Currency Switcher Options. |
|
| 200 | - $this->menus = get_theme_mod( 'lsx_currencies_currency_menu_position', false ); |
|
| 201 | - |
|
| 202 | - if ( get_theme_mod( 'lsx_currencies_display_flags', false ) ) { |
|
| 203 | - $this->display_flags = true; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - if ( get_theme_mod( 'lsx_currencies_flag_position', false ) ) { |
|
| 207 | - $this->flag_position = 'right'; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - if ( get_theme_mod( 'lsx_currencies_currency_switcher_position', false ) ) { |
|
| 211 | - $this->switcher_symbol_position = 'left'; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - $this->available_currencies = $this->get_available_currencies(); |
|
| 215 | - $this->flag_relations = $this->get_flag_relations(); |
|
| 216 | - $this->currency_symbols = $this->get_currency_symbols(); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Returns Currency Flag for currency code provided |
|
| 221 | - * |
|
| 222 | - * @param $key string |
|
| 223 | - * @return string |
|
| 224 | - */ |
|
| 225 | - public function get_currency_flag( $key = 'USD' ) { |
|
| 226 | - $key = strtoupper( $key ); |
|
| 227 | - return '<span class="flag-icon flag-icon-' . $this->flag_relations[ $key ] . '"></span> '; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Get Currency symbol. |
|
| 232 | - * |
|
| 233 | - * @param string $currency |
|
| 234 | - * @return string |
|
| 235 | - */ |
|
| 236 | - public function get_currency_symbol( $currency = '' ) { |
|
| 237 | - if ( ! $currency ) { |
|
| 238 | - $currency = $this->base_currency; |
|
| 239 | - } |
|
| 240 | - $currency_symbol = isset( $this->currency_symbols[ $currency ] ) ? $this->currency_symbols[ $currency ] : ''; |
|
| 241 | - return $currency_symbol; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * Returns an array of the available currencies |
|
| 246 | - * |
|
| 247 | - * @return array |
|
| 248 | - */ |
|
| 249 | - public function get_available_currencies() { |
|
| 250 | - |
|
| 251 | - $paid_currencies = array( |
|
| 252 | - 'BWP' => esc_html__( 'Botswana Pula', 'lsx-currencies' ), |
|
| 253 | - 'KES' => esc_html__( 'Kenyan Shilling', 'lsx-currencies' ), |
|
| 254 | - 'LAK' => esc_html__( 'Laos Kip', 'lsx-currencies' ), |
|
| 255 | - 'MWK' => esc_html__( 'Malawian Kwacha', 'lsx-currencies' ), |
|
| 256 | - 'MZN' => esc_html__( 'Mozambique Metical', 'lsx-currencies' ), |
|
| 257 | - 'NAD' => esc_html__( 'Namibian Dollar', 'lsx-currencies' ), |
|
| 258 | - 'TZS' => esc_html__( 'Tanzania Shilling', 'lsx-currencies' ), |
|
| 259 | - 'AED' => esc_html__( 'United Arab Emirates Dirham', 'lsx-currencies' ), |
|
| 260 | - 'ZMW' => esc_html__( 'Zambian Kwacha', 'lsx-currencies' ), |
|
| 261 | - 'ZWL' => esc_html__( 'Zimbabwean Dollar', 'lsx-currencies' ), |
|
| 262 | - ); |
|
| 263 | - $free_currencies = array( |
|
| 264 | - 'AUD' => esc_html__( 'Australian Dollar', 'lsx-currencies' ), |
|
| 265 | - 'BRL' => esc_html__( 'Brazilian Real', 'lsx-currencies' ), |
|
| 266 | - 'GBP' => esc_html__( 'British Pound Sterling', 'lsx-currencies' ), |
|
| 267 | - 'CAD' => esc_html__( 'Canadian Dollar', 'lsx-currencies' ), |
|
| 268 | - 'CNY' => esc_html__( 'Chinese Yuan', 'lsx-currencies' ), |
|
| 269 | - 'EUR' => esc_html__( 'Euro', 'lsx-currencies' ), |
|
| 270 | - 'HKD' => esc_html__( 'Hong Kong Dollar', 'lsx-currencies' ), |
|
| 271 | - 'INR' => esc_html__( 'Indian Rupee', 'lsx-currencies' ), |
|
| 272 | - 'IDR' => esc_html__( 'Indonesia Rupiah', 'lsx-currencies' ), |
|
| 273 | - 'ILS' => esc_html__( 'Israeli Shekel', 'lsx-currencies' ), |
|
| 274 | - 'JPY' => esc_html__( 'Japanese Yen', 'lsx-currencies' ), |
|
| 275 | - 'MYR' => esc_html__( 'Malaysia Ringgit', 'lsx-currencies' ), |
|
| 276 | - 'NOK' => esc_html__( 'Norwegian Krone', 'lsx-currencies' ), |
|
| 277 | - 'NZD' => esc_html__( 'New Zealand Dollar', 'lsx-currencies' ), |
|
| 278 | - 'RUB' => esc_html__( 'Russian Ruble', 'lsx-currencies' ), |
|
| 279 | - 'SGD' => esc_html__( 'Singapore Dollar', 'lsx-currencies' ), |
|
| 280 | - 'ZAR' => esc_html__( 'South African Rand', 'lsx-currencies' ), |
|
| 281 | - 'SEK' => esc_html__( 'Swedish Krona', 'lsx-currencies' ), |
|
| 282 | - 'CHF' => esc_html__( 'Swiss Franc', 'lsx-currencies' ), |
|
| 283 | - 'USD' => esc_html__( 'United States Dollar', 'lsx-currencies' ), |
|
| 284 | - ); |
|
| 285 | - |
|
| 286 | - if ( false !== $this->app_id ) { |
|
| 287 | - $free_currencies = array_merge( $free_currencies, $paid_currencies ); |
|
| 288 | - asort( $free_currencies ); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return $free_currencies; |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * Returns the ISO 3 code in relation to its 2 code values. |
|
| 296 | - * |
|
| 297 | - * @return array |
|
| 298 | - */ |
|
| 299 | - public function get_flag_relations() { |
|
| 300 | - return array( |
|
| 301 | - 'AUD' => 'au', |
|
| 302 | - 'BRL' => 'br', |
|
| 303 | - 'GBP' => 'gb', |
|
| 304 | - 'BWP' => 'bw', |
|
| 305 | - 'CAD' => 'ca', |
|
| 306 | - 'CNY' => 'cn', |
|
| 307 | - 'EUR' => 'eu', |
|
| 308 | - 'HKD' => 'hk', |
|
| 309 | - 'INR' => 'in', |
|
| 310 | - 'IDR' => 'id', |
|
| 311 | - 'ILS' => 'il', |
|
| 312 | - 'JPY' => 'jp', |
|
| 313 | - 'KES' => 'ke', |
|
| 314 | - 'LAK' => 'la', |
|
| 315 | - 'MWK' => 'mw', |
|
| 316 | - 'MYR' => 'my', |
|
| 317 | - 'MZN' => 'mz', |
|
| 318 | - 'NAD' => 'na', |
|
| 319 | - 'NZD' => 'nz', |
|
| 320 | - 'NOK' => 'no', |
|
| 321 | - 'RUB' => 'ru', |
|
| 322 | - 'SGD' => 'sg', |
|
| 323 | - 'ZAR' => 'za', |
|
| 324 | - 'SEK' => 'se', |
|
| 325 | - 'CHF' => 'ch', |
|
| 326 | - 'TZS' => 'tz', |
|
| 327 | - 'USD' => 'us', |
|
| 328 | - 'AED' => 'ae', |
|
| 329 | - 'ZMW' => 'zm', |
|
| 330 | - 'ZWL' => 'zw', |
|
| 331 | - ); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - /** |
|
| 335 | - * Returns all of the currency symbols. |
|
| 336 | - * |
|
| 337 | - * @return array |
|
| 338 | - */ |
|
| 339 | - public function get_currency_symbols() { |
|
| 340 | - return apply_filters( 'lsx_currencies_symbols', array( |
|
| 341 | - 'AED' => 'د.إ', |
|
| 342 | - 'AFN' => '؋', |
|
| 343 | - 'ALL' => 'L', |
|
| 344 | - 'AMD' => 'AMD', |
|
| 345 | - 'ANG' => 'ƒ', |
|
| 346 | - 'AOA' => 'Kz', |
|
| 347 | - 'ARS' => '$', |
|
| 348 | - 'AUD' => '$', |
|
| 349 | - 'AWG' => 'Afl.', |
|
| 350 | - 'AZN' => 'AZN', |
|
| 351 | - 'BAM' => 'KM', |
|
| 352 | - 'BBD' => '$', |
|
| 353 | - 'BDT' => '৳ ', |
|
| 354 | - 'BGN' => 'лв.', |
|
| 355 | - 'BHD' => '.د.ب', |
|
| 356 | - 'BIF' => 'Fr', |
|
| 357 | - 'BMD' => '$', |
|
| 358 | - 'BND' => '$', |
|
| 359 | - 'BOB' => 'Bs.', |
|
| 360 | - 'BRL' => 'R$', |
|
| 361 | - 'BSD' => '$', |
|
| 362 | - 'BTC' => '฿', |
|
| 363 | - 'BTN' => 'Nu.', |
|
| 364 | - 'BWP' => 'P', |
|
| 365 | - 'BYR' => 'Br', |
|
| 366 | - 'BZD' => '$', |
|
| 367 | - 'CAD' => '$', |
|
| 368 | - 'CDF' => 'Fr', |
|
| 369 | - 'CHF' => 'CHF', |
|
| 370 | - 'CLP' => '$', |
|
| 371 | - 'CNY' => '¥', |
|
| 372 | - 'COP' => '$', |
|
| 373 | - 'CRC' => '₡', |
|
| 374 | - 'CUC' => '$', |
|
| 375 | - 'CUP' => '$', |
|
| 376 | - 'CVE' => '$', |
|
| 377 | - 'CZK' => 'Kč', |
|
| 378 | - 'DJF' => 'Fr', |
|
| 379 | - 'DKK' => 'DKK', |
|
| 380 | - 'DOP' => 'RD$', |
|
| 381 | - 'DZD' => 'د.ج', |
|
| 382 | - 'EGP' => 'EGP', |
|
| 383 | - 'ERN' => 'Nfk', |
|
| 384 | - 'ETB' => 'Br', |
|
| 385 | - 'EUR' => '€', |
|
| 386 | - 'FJD' => '$', |
|
| 387 | - 'FKP' => '£', |
|
| 388 | - 'GBP' => '£', |
|
| 389 | - 'GEL' => 'ლ', |
|
| 390 | - 'GGP' => '£', |
|
| 391 | - 'GHS' => '₵', |
|
| 392 | - 'GIP' => '£', |
|
| 393 | - 'GMD' => 'D', |
|
| 394 | - 'GNF' => 'Fr', |
|
| 395 | - 'GTQ' => 'Q', |
|
| 396 | - 'GYD' => '$', |
|
| 397 | - 'HKD' => '$', |
|
| 398 | - 'HNL' => 'L', |
|
| 399 | - 'HRK' => 'Kn', |
|
| 400 | - 'HTG' => 'G', |
|
| 401 | - 'HUF' => 'Ft', |
|
| 402 | - 'IDR' => 'Rp', |
|
| 403 | - 'ILS' => '₪', |
|
| 404 | - 'IMP' => '£', |
|
| 405 | - 'INR' => '₹', |
|
| 406 | - 'IQD' => 'ع.د', |
|
| 407 | - 'IRR' => '﷼', |
|
| 408 | - 'IRT' => 'تومان', |
|
| 409 | - 'ISK' => 'kr.', |
|
| 410 | - 'JEP' => '£', |
|
| 411 | - 'JMD' => '$', |
|
| 412 | - 'JOD' => 'د.ا', |
|
| 413 | - 'JPY' => '¥', |
|
| 414 | - 'KES' => 'KSh', |
|
| 415 | - 'KGS' => 'сом', |
|
| 416 | - 'KHR' => '៛', |
|
| 417 | - 'KMF' => 'Fr', |
|
| 418 | - 'KPW' => '₩', |
|
| 419 | - 'KRW' => '₩', |
|
| 420 | - 'KWD' => 'د.ك', |
|
| 421 | - 'KYD' => '$', |
|
| 422 | - 'KZT' => 'KZT', |
|
| 423 | - 'LAK' => '₭', |
|
| 424 | - 'LBP' => 'ل.ل', |
|
| 425 | - 'LKR' => 'රු', |
|
| 426 | - 'LRD' => '$', |
|
| 427 | - 'LSL' => 'L', |
|
| 428 | - 'LYD' => 'ل.د', |
|
| 429 | - 'MAD' => 'د.م.', |
|
| 430 | - 'MDL' => 'MDL', |
|
| 431 | - 'MGA' => 'Ar', |
|
| 432 | - 'MKD' => 'ден', |
|
| 433 | - 'MMK' => 'Ks', |
|
| 434 | - 'MNT' => '₮', |
|
| 435 | - 'MOP' => 'P', |
|
| 436 | - 'MRO' => 'UM', |
|
| 437 | - 'MUR' => '₨', |
|
| 438 | - 'MVR' => '.ރ', |
|
| 439 | - 'MWK' => 'MK', |
|
| 440 | - 'MXN' => '$', |
|
| 441 | - 'MYR' => 'RM', |
|
| 442 | - 'MZN' => 'MT', |
|
| 443 | - 'NAD' => '$', |
|
| 444 | - 'NGN' => '₦', |
|
| 445 | - 'NIO' => 'C$', |
|
| 446 | - 'NOK' => 'kr', |
|
| 447 | - 'NPR' => '₨', |
|
| 448 | - 'NZD' => '$', |
|
| 449 | - 'OMR' => 'ر.ع.', |
|
| 450 | - 'PAB' => 'B/.', |
|
| 451 | - 'PEN' => 'S/.', |
|
| 452 | - 'PGK' => 'K', |
|
| 453 | - 'PHP' => '₱', |
|
| 454 | - 'PKR' => '₨', |
|
| 455 | - 'PLN' => 'zł', |
|
| 456 | - 'PRB' => 'р.', |
|
| 457 | - 'PYG' => '₲', |
|
| 458 | - 'QAR' => 'ر.ق', |
|
| 459 | - 'RMB' => '¥', |
|
| 460 | - 'RON' => 'lei', |
|
| 461 | - 'RSD' => 'дин.', |
|
| 462 | - 'RUB' => '₽', |
|
| 463 | - 'RWF' => 'Fr', |
|
| 464 | - 'SAR' => 'ر.س', |
|
| 465 | - 'SBD' => '$', |
|
| 466 | - 'SCR' => '₨', |
|
| 467 | - 'SDG' => 'ج.س.', |
|
| 468 | - 'SEK' => 'kr', |
|
| 469 | - 'SGD' => '$', |
|
| 470 | - 'SHP' => '£', |
|
| 471 | - 'SLL' => 'Le', |
|
| 472 | - 'SOS' => 'Sh', |
|
| 473 | - 'SRD' => '$', |
|
| 474 | - 'SSP' => '£', |
|
| 475 | - 'STD' => 'Db', |
|
| 476 | - 'SYP' => 'ل.س', |
|
| 477 | - 'SZL' => 'L', |
|
| 478 | - 'THB' => '฿', |
|
| 479 | - 'TJS' => 'ЅМ', |
|
| 480 | - 'TMT' => 'm', |
|
| 481 | - 'TND' => 'د.ت', |
|
| 482 | - 'TOP' => 'T$', |
|
| 483 | - 'TRY' => '₺', |
|
| 484 | - 'TTD' => '$', |
|
| 485 | - 'TWD' => 'NT$', |
|
| 486 | - 'TZS' => 'Sh', |
|
| 487 | - 'UAH' => '₴', |
|
| 488 | - 'UGX' => 'UGX', |
|
| 489 | - 'USD' => '$', |
|
| 490 | - 'UYU' => '$', |
|
| 491 | - 'UZS' => 'UZS', |
|
| 492 | - 'VEF' => 'Bs F', |
|
| 493 | - 'VND' => '₫', |
|
| 494 | - 'VUV' => 'Vt', |
|
| 495 | - 'WST' => 'T', |
|
| 496 | - 'XAF' => 'Fr', |
|
| 497 | - 'XCD' => '$', |
|
| 498 | - 'XOF' => 'Fr', |
|
| 499 | - 'XPF' => 'Fr', |
|
| 500 | - 'YER' => '﷼', |
|
| 501 | - 'ZAR' => 'R', |
|
| 502 | - 'ZMW' => 'ZK', |
|
| 503 | - ) ); |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - /** |
|
| 507 | - * Sanitize checkbox. |
|
| 508 | - * |
|
| 509 | - * @param $input html |
|
| 510 | - * @return mixed |
|
| 511 | - */ |
|
| 512 | - public function sanitize_checkbox( $input ) { |
|
| 513 | - return ( 1 === absint( $input ) ) ? 1 : 0; |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - /** |
|
| 517 | - * Sanitize select. |
|
| 518 | - * |
|
| 519 | - * @param $input html |
|
| 520 | - * @return mixed |
|
| 521 | - */ |
|
| 522 | - public function sanitize_select( $input ) { |
|
| 523 | - if ( is_string( $input ) || is_integer( $input ) || is_bool( $input ) ) { |
|
| 524 | - return $input; |
|
| 525 | - } else { |
|
| 526 | - return ''; |
|
| 527 | - } |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - /** |
|
| 531 | - * Sanitize textarea. |
|
| 532 | - * |
|
| 533 | - * @param $input html |
|
| 534 | - * @return mixed |
|
| 535 | - */ |
|
| 536 | - public function sanitize_textarea( $input ) { |
|
| 537 | - return wp_kses_post( $input ); |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - /** |
|
| 541 | - * Migrate the old data (from UIX) to WP Customizer settings. |
|
| 542 | - * |
|
| 543 | - * @since 1.1.1 |
|
| 544 | - */ |
|
| 545 | - public function migration_uix_to_customize() { |
|
| 546 | - $visual_tab_migration = get_theme_mod( 'lsx_currencies_visual_tab_migration', false ); |
|
| 547 | - |
|
| 548 | - if ( empty( $visual_tab_migration ) ) { |
|
| 549 | - if ( isset( $this->options['display'] ) ) { |
|
| 550 | - if ( isset( $this->options['display']['currency_menu_switcher'] ) && is_array( $this->options['display']['currency_menu_switcher'] ) && ! empty( $this->options['display']['currency_menu_switcher'] ) ) { |
|
| 551 | - $currency_menu_position = $this->options['display']['currency_menu_switcher']; |
|
| 552 | - |
|
| 553 | - foreach ( $currency_menu_position as $key => $value ) { |
|
| 554 | - set_theme_mod( 'lsx_currencies_currency_menu_position', $key ); |
|
| 555 | - break; |
|
| 556 | - } |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - if ( isset( $this->options['display']['display_flags'] ) && 'on' === $this->options['display']['display_flags'] ) { |
|
| 560 | - set_theme_mod( 'lsx_currencies_display_flags', true ); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - if ( isset( $this->options['display']['flag_position'] ) && 'on' === $this->options['display']['flag_position'] ) { |
|
| 564 | - set_theme_mod( 'lsx_currencies_flag_position', 'right' ); |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - if ( isset( $this->options['display']['currency_switcher_position'] ) && 'on' === $this->options['display']['currency_switcher_position'] ) { |
|
| 568 | - set_theme_mod( 'lsx_currencies_currency_switcher_position', 'left' ); |
|
| 569 | - } |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - set_theme_mod( 'lsx_currencies_visual_tab_migration', true ); |
|
| 573 | - } |
|
| 574 | - } |
|
| 19 | + /** |
|
| 20 | + * Holds instance of the class |
|
| 21 | + * |
|
| 22 | + * @var object \lsx\currencies\classes\Currencies() |
|
| 23 | + */ |
|
| 24 | + private static $instance; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Holds the admin instance |
|
| 28 | + * |
|
| 29 | + * @var object \lsx\currencies\classes\Admin() |
|
| 30 | + */ |
|
| 31 | + public $admin; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Holds the frontend instance |
|
| 35 | + * |
|
| 36 | + * @var object \lsx\currencies\classes\Frontedn() |
|
| 37 | + */ |
|
| 38 | + public $frontend; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Holds the woocommerce instance |
|
| 42 | + * |
|
| 43 | + * @var object \lsx\currencies\classes\WooCommerce() |
|
| 44 | + */ |
|
| 45 | + public $woocommerce; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Holds the FacetWP instance |
|
| 49 | + * |
|
| 50 | + * @var object \lsx\currencies\classes\FacetWP() |
|
| 51 | + */ |
|
| 52 | + public $facetwp; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * This hold the URL, it defaults to the free exchange rates. |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + public $api_url = 'https://api.exchangeratesapi.io/latest?base=USD'; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * General Parameters |
|
| 63 | + */ |
|
| 64 | + /** @var string */ |
|
| 65 | + public $plugin_slug = 'lsx-currencies'; |
|
| 66 | + |
|
| 67 | + /** @var array */ |
|
| 68 | + public $options = false; |
|
| 69 | + |
|
| 70 | + /** @var string */ |
|
| 71 | + public $base_currency = 'USD'; |
|
| 72 | + |
|
| 73 | + /** @var array */ |
|
| 74 | + public $additional_currencies = array(); |
|
| 75 | + |
|
| 76 | + /** @var array */ |
|
| 77 | + public $available_currencies = array(); |
|
| 78 | + |
|
| 79 | + /** @var array */ |
|
| 80 | + public $flag_relations = array(); |
|
| 81 | + |
|
| 82 | + /** @var array */ |
|
| 83 | + public $currency_symbols = array(); |
|
| 84 | + |
|
| 85 | + /** @var boolean */ |
|
| 86 | + public $multi_prices = false; |
|
| 87 | + |
|
| 88 | + /** @var boolean */ |
|
| 89 | + public $convert_to_single = false; |
|
| 90 | + |
|
| 91 | + /** @var boolean */ |
|
| 92 | + public $app_id = false; |
|
| 93 | + |
|
| 94 | + /* Currency Switcher Options */ |
|
| 95 | + /** @var array */ |
|
| 96 | + public $menus = false; |
|
| 97 | + |
|
| 98 | + /** @var boolean */ |
|
| 99 | + public $display_flags = false; |
|
| 100 | + |
|
| 101 | + /** @var string */ |
|
| 102 | + public $flag_position = 'left'; |
|
| 103 | + |
|
| 104 | + /** @var string */ |
|
| 105 | + public $switcher_symbol_position = 'right'; |
|
| 106 | + |
|
| 107 | + /** @var boolean */ |
|
| 108 | + public $remove_decimals = false; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Constructor |
|
| 112 | + */ |
|
| 113 | + public function __construct() { |
|
| 114 | + add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); |
|
| 115 | + add_action( 'plugins_loaded', array( $this, 'set_defaults' ) ); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * Return an instance of this class. |
|
| 120 | + * |
|
| 121 | + * @return object |
|
| 122 | + */ |
|
| 123 | + public static function init() { |
|
| 124 | + // If the single instance hasn't been set, set it now. |
|
| 125 | + if ( ! isset( self::$instance ) ) { |
|
| 126 | + self::$instance = new self(); |
|
| 127 | + } |
|
| 128 | + return self::$instance; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * After active plugins and pluggable functions are loaded |
|
| 133 | + */ |
|
| 134 | + public function plugins_loaded() { |
|
| 135 | + require_once LSX_CURRENCIES_PATH . 'classes/class-admin.php'; |
|
| 136 | + $this->admin = \lsx\currencies\classes\Admin::init(); |
|
| 137 | + |
|
| 138 | + require_once LSX_CURRENCIES_PATH . 'classes/class-frontend.php'; |
|
| 139 | + $this->frontend = \lsx\currencies\classes\Frontend::init(); |
|
| 140 | + |
|
| 141 | + if ( class_exists( 'WooCommerce' ) ) { |
|
| 142 | + require_once LSX_CURRENCIES_PATH . 'classes/class-woocommerce.php'; |
|
| 143 | + $this->woocommerce = \lsx\currencies\classes\WooCommerce::init(); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + if ( class_exists( 'FacetWP' ) ) { |
|
| 147 | + require_once LSX_CURRENCIES_PATH . 'classes/class-facetwp.php'; |
|
| 148 | + $this->facetwp = \lsx\currencies\classes\FacetWP::init(); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + require_once LSX_CURRENCIES_PATH . '/includes/template-tags.php'; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Get the options |
|
| 156 | + */ |
|
| 157 | + public function set_defaults() { |
|
| 158 | + $settings_tab = 'display'; |
|
| 159 | + if ( function_exists( 'tour_operator' ) ) { |
|
| 160 | + $options = get_option( '_lsx-to_settings', false ); |
|
| 161 | + $settings_tab = 'general'; |
|
| 162 | + } else { |
|
| 163 | + $options = get_option( '_lsx_settings', false ); |
|
| 164 | + |
|
| 165 | + if ( false === $options ) { |
|
| 166 | + $options = get_option( '_lsx_lsx-settings', false ); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + if ( false !== $options ) { |
|
| 171 | + $this->options = $options; |
|
| 172 | + $this->migration_uix_to_customize(); |
|
| 173 | + |
|
| 174 | + if ( isset( $this->options[ $settings_tab ] ) && isset( $this->options[ $settings_tab ]['currency'] ) ) { |
|
| 175 | + $this->base_currency = apply_filters( 'lsx_currencies_base_currency', $this->options[ $settings_tab ]['currency'], $this ); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + if ( isset( $this->options[ $settings_tab ]['additional_currencies'] ) && is_array( $this->options[ $settings_tab ]['additional_currencies'] ) && ! empty( $this->options[ $settings_tab ]['additional_currencies'] ) ) { |
|
| 179 | + $this->additional_currencies = $this->options[ $settings_tab ]['additional_currencies']; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + if ( isset( $this->options[ $settings_tab ]['multi_price'] ) && 'on' === $this->options[ $settings_tab ]['multi_price'] ) { |
|
| 183 | + $this->multi_prices = true; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + if ( isset( $this->options[ $settings_tab ]['convert_to_single_currency'] ) && 'on' === $this->options[ $settings_tab ]['convert_to_single_currency'] ) { |
|
| 187 | + $this->convert_to_single = true; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + if ( isset( $this->options[ $settings_tab ]['remove_decimals'] ) && 'on' === $this->options[ $settings_tab ]['remove_decimals'] ) { |
|
| 191 | + $this->remove_decimals = true; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + if ( isset( $this->options['api']['openexchange_api'] ) && '' !== $this->options['api']['openexchange_api'] ) { |
|
| 195 | + $this->app_id = $this->options['api']['openexchange_api']; |
|
| 196 | + $this->api_url = 'http://openexchangerates.org/api/latest.json?app_id=' . $this->app_id; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + // Currency Switcher Options. |
|
| 200 | + $this->menus = get_theme_mod( 'lsx_currencies_currency_menu_position', false ); |
|
| 201 | + |
|
| 202 | + if ( get_theme_mod( 'lsx_currencies_display_flags', false ) ) { |
|
| 203 | + $this->display_flags = true; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + if ( get_theme_mod( 'lsx_currencies_flag_position', false ) ) { |
|
| 207 | + $this->flag_position = 'right'; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + if ( get_theme_mod( 'lsx_currencies_currency_switcher_position', false ) ) { |
|
| 211 | + $this->switcher_symbol_position = 'left'; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + $this->available_currencies = $this->get_available_currencies(); |
|
| 215 | + $this->flag_relations = $this->get_flag_relations(); |
|
| 216 | + $this->currency_symbols = $this->get_currency_symbols(); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Returns Currency Flag for currency code provided |
|
| 221 | + * |
|
| 222 | + * @param $key string |
|
| 223 | + * @return string |
|
| 224 | + */ |
|
| 225 | + public function get_currency_flag( $key = 'USD' ) { |
|
| 226 | + $key = strtoupper( $key ); |
|
| 227 | + return '<span class="flag-icon flag-icon-' . $this->flag_relations[ $key ] . '"></span> '; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Get Currency symbol. |
|
| 232 | + * |
|
| 233 | + * @param string $currency |
|
| 234 | + * @return string |
|
| 235 | + */ |
|
| 236 | + public function get_currency_symbol( $currency = '' ) { |
|
| 237 | + if ( ! $currency ) { |
|
| 238 | + $currency = $this->base_currency; |
|
| 239 | + } |
|
| 240 | + $currency_symbol = isset( $this->currency_symbols[ $currency ] ) ? $this->currency_symbols[ $currency ] : ''; |
|
| 241 | + return $currency_symbol; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * Returns an array of the available currencies |
|
| 246 | + * |
|
| 247 | + * @return array |
|
| 248 | + */ |
|
| 249 | + public function get_available_currencies() { |
|
| 250 | + |
|
| 251 | + $paid_currencies = array( |
|
| 252 | + 'BWP' => esc_html__( 'Botswana Pula', 'lsx-currencies' ), |
|
| 253 | + 'KES' => esc_html__( 'Kenyan Shilling', 'lsx-currencies' ), |
|
| 254 | + 'LAK' => esc_html__( 'Laos Kip', 'lsx-currencies' ), |
|
| 255 | + 'MWK' => esc_html__( 'Malawian Kwacha', 'lsx-currencies' ), |
|
| 256 | + 'MZN' => esc_html__( 'Mozambique Metical', 'lsx-currencies' ), |
|
| 257 | + 'NAD' => esc_html__( 'Namibian Dollar', 'lsx-currencies' ), |
|
| 258 | + 'TZS' => esc_html__( 'Tanzania Shilling', 'lsx-currencies' ), |
|
| 259 | + 'AED' => esc_html__( 'United Arab Emirates Dirham', 'lsx-currencies' ), |
|
| 260 | + 'ZMW' => esc_html__( 'Zambian Kwacha', 'lsx-currencies' ), |
|
| 261 | + 'ZWL' => esc_html__( 'Zimbabwean Dollar', 'lsx-currencies' ), |
|
| 262 | + ); |
|
| 263 | + $free_currencies = array( |
|
| 264 | + 'AUD' => esc_html__( 'Australian Dollar', 'lsx-currencies' ), |
|
| 265 | + 'BRL' => esc_html__( 'Brazilian Real', 'lsx-currencies' ), |
|
| 266 | + 'GBP' => esc_html__( 'British Pound Sterling', 'lsx-currencies' ), |
|
| 267 | + 'CAD' => esc_html__( 'Canadian Dollar', 'lsx-currencies' ), |
|
| 268 | + 'CNY' => esc_html__( 'Chinese Yuan', 'lsx-currencies' ), |
|
| 269 | + 'EUR' => esc_html__( 'Euro', 'lsx-currencies' ), |
|
| 270 | + 'HKD' => esc_html__( 'Hong Kong Dollar', 'lsx-currencies' ), |
|
| 271 | + 'INR' => esc_html__( 'Indian Rupee', 'lsx-currencies' ), |
|
| 272 | + 'IDR' => esc_html__( 'Indonesia Rupiah', 'lsx-currencies' ), |
|
| 273 | + 'ILS' => esc_html__( 'Israeli Shekel', 'lsx-currencies' ), |
|
| 274 | + 'JPY' => esc_html__( 'Japanese Yen', 'lsx-currencies' ), |
|
| 275 | + 'MYR' => esc_html__( 'Malaysia Ringgit', 'lsx-currencies' ), |
|
| 276 | + 'NOK' => esc_html__( 'Norwegian Krone', 'lsx-currencies' ), |
|
| 277 | + 'NZD' => esc_html__( 'New Zealand Dollar', 'lsx-currencies' ), |
|
| 278 | + 'RUB' => esc_html__( 'Russian Ruble', 'lsx-currencies' ), |
|
| 279 | + 'SGD' => esc_html__( 'Singapore Dollar', 'lsx-currencies' ), |
|
| 280 | + 'ZAR' => esc_html__( 'South African Rand', 'lsx-currencies' ), |
|
| 281 | + 'SEK' => esc_html__( 'Swedish Krona', 'lsx-currencies' ), |
|
| 282 | + 'CHF' => esc_html__( 'Swiss Franc', 'lsx-currencies' ), |
|
| 283 | + 'USD' => esc_html__( 'United States Dollar', 'lsx-currencies' ), |
|
| 284 | + ); |
|
| 285 | + |
|
| 286 | + if ( false !== $this->app_id ) { |
|
| 287 | + $free_currencies = array_merge( $free_currencies, $paid_currencies ); |
|
| 288 | + asort( $free_currencies ); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return $free_currencies; |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * Returns the ISO 3 code in relation to its 2 code values. |
|
| 296 | + * |
|
| 297 | + * @return array |
|
| 298 | + */ |
|
| 299 | + public function get_flag_relations() { |
|
| 300 | + return array( |
|
| 301 | + 'AUD' => 'au', |
|
| 302 | + 'BRL' => 'br', |
|
| 303 | + 'GBP' => 'gb', |
|
| 304 | + 'BWP' => 'bw', |
|
| 305 | + 'CAD' => 'ca', |
|
| 306 | + 'CNY' => 'cn', |
|
| 307 | + 'EUR' => 'eu', |
|
| 308 | + 'HKD' => 'hk', |
|
| 309 | + 'INR' => 'in', |
|
| 310 | + 'IDR' => 'id', |
|
| 311 | + 'ILS' => 'il', |
|
| 312 | + 'JPY' => 'jp', |
|
| 313 | + 'KES' => 'ke', |
|
| 314 | + 'LAK' => 'la', |
|
| 315 | + 'MWK' => 'mw', |
|
| 316 | + 'MYR' => 'my', |
|
| 317 | + 'MZN' => 'mz', |
|
| 318 | + 'NAD' => 'na', |
|
| 319 | + 'NZD' => 'nz', |
|
| 320 | + 'NOK' => 'no', |
|
| 321 | + 'RUB' => 'ru', |
|
| 322 | + 'SGD' => 'sg', |
|
| 323 | + 'ZAR' => 'za', |
|
| 324 | + 'SEK' => 'se', |
|
| 325 | + 'CHF' => 'ch', |
|
| 326 | + 'TZS' => 'tz', |
|
| 327 | + 'USD' => 'us', |
|
| 328 | + 'AED' => 'ae', |
|
| 329 | + 'ZMW' => 'zm', |
|
| 330 | + 'ZWL' => 'zw', |
|
| 331 | + ); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + /** |
|
| 335 | + * Returns all of the currency symbols. |
|
| 336 | + * |
|
| 337 | + * @return array |
|
| 338 | + */ |
|
| 339 | + public function get_currency_symbols() { |
|
| 340 | + return apply_filters( 'lsx_currencies_symbols', array( |
|
| 341 | + 'AED' => 'د.إ', |
|
| 342 | + 'AFN' => '؋', |
|
| 343 | + 'ALL' => 'L', |
|
| 344 | + 'AMD' => 'AMD', |
|
| 345 | + 'ANG' => 'ƒ', |
|
| 346 | + 'AOA' => 'Kz', |
|
| 347 | + 'ARS' => '$', |
|
| 348 | + 'AUD' => '$', |
|
| 349 | + 'AWG' => 'Afl.', |
|
| 350 | + 'AZN' => 'AZN', |
|
| 351 | + 'BAM' => 'KM', |
|
| 352 | + 'BBD' => '$', |
|
| 353 | + 'BDT' => '৳ ', |
|
| 354 | + 'BGN' => 'лв.', |
|
| 355 | + 'BHD' => '.د.ب', |
|
| 356 | + 'BIF' => 'Fr', |
|
| 357 | + 'BMD' => '$', |
|
| 358 | + 'BND' => '$', |
|
| 359 | + 'BOB' => 'Bs.', |
|
| 360 | + 'BRL' => 'R$', |
|
| 361 | + 'BSD' => '$', |
|
| 362 | + 'BTC' => '฿', |
|
| 363 | + 'BTN' => 'Nu.', |
|
| 364 | + 'BWP' => 'P', |
|
| 365 | + 'BYR' => 'Br', |
|
| 366 | + 'BZD' => '$', |
|
| 367 | + 'CAD' => '$', |
|
| 368 | + 'CDF' => 'Fr', |
|
| 369 | + 'CHF' => 'CHF', |
|
| 370 | + 'CLP' => '$', |
|
| 371 | + 'CNY' => '¥', |
|
| 372 | + 'COP' => '$', |
|
| 373 | + 'CRC' => '₡', |
|
| 374 | + 'CUC' => '$', |
|
| 375 | + 'CUP' => '$', |
|
| 376 | + 'CVE' => '$', |
|
| 377 | + 'CZK' => 'Kč', |
|
| 378 | + 'DJF' => 'Fr', |
|
| 379 | + 'DKK' => 'DKK', |
|
| 380 | + 'DOP' => 'RD$', |
|
| 381 | + 'DZD' => 'د.ج', |
|
| 382 | + 'EGP' => 'EGP', |
|
| 383 | + 'ERN' => 'Nfk', |
|
| 384 | + 'ETB' => 'Br', |
|
| 385 | + 'EUR' => '€', |
|
| 386 | + 'FJD' => '$', |
|
| 387 | + 'FKP' => '£', |
|
| 388 | + 'GBP' => '£', |
|
| 389 | + 'GEL' => 'ლ', |
|
| 390 | + 'GGP' => '£', |
|
| 391 | + 'GHS' => '₵', |
|
| 392 | + 'GIP' => '£', |
|
| 393 | + 'GMD' => 'D', |
|
| 394 | + 'GNF' => 'Fr', |
|
| 395 | + 'GTQ' => 'Q', |
|
| 396 | + 'GYD' => '$', |
|
| 397 | + 'HKD' => '$', |
|
| 398 | + 'HNL' => 'L', |
|
| 399 | + 'HRK' => 'Kn', |
|
| 400 | + 'HTG' => 'G', |
|
| 401 | + 'HUF' => 'Ft', |
|
| 402 | + 'IDR' => 'Rp', |
|
| 403 | + 'ILS' => '₪', |
|
| 404 | + 'IMP' => '£', |
|
| 405 | + 'INR' => '₹', |
|
| 406 | + 'IQD' => 'ع.د', |
|
| 407 | + 'IRR' => '﷼', |
|
| 408 | + 'IRT' => 'تومان', |
|
| 409 | + 'ISK' => 'kr.', |
|
| 410 | + 'JEP' => '£', |
|
| 411 | + 'JMD' => '$', |
|
| 412 | + 'JOD' => 'د.ا', |
|
| 413 | + 'JPY' => '¥', |
|
| 414 | + 'KES' => 'KSh', |
|
| 415 | + 'KGS' => 'сом', |
|
| 416 | + 'KHR' => '៛', |
|
| 417 | + 'KMF' => 'Fr', |
|
| 418 | + 'KPW' => '₩', |
|
| 419 | + 'KRW' => '₩', |
|
| 420 | + 'KWD' => 'د.ك', |
|
| 421 | + 'KYD' => '$', |
|
| 422 | + 'KZT' => 'KZT', |
|
| 423 | + 'LAK' => '₭', |
|
| 424 | + 'LBP' => 'ل.ل', |
|
| 425 | + 'LKR' => 'රු', |
|
| 426 | + 'LRD' => '$', |
|
| 427 | + 'LSL' => 'L', |
|
| 428 | + 'LYD' => 'ل.د', |
|
| 429 | + 'MAD' => 'د.م.', |
|
| 430 | + 'MDL' => 'MDL', |
|
| 431 | + 'MGA' => 'Ar', |
|
| 432 | + 'MKD' => 'ден', |
|
| 433 | + 'MMK' => 'Ks', |
|
| 434 | + 'MNT' => '₮', |
|
| 435 | + 'MOP' => 'P', |
|
| 436 | + 'MRO' => 'UM', |
|
| 437 | + 'MUR' => '₨', |
|
| 438 | + 'MVR' => '.ރ', |
|
| 439 | + 'MWK' => 'MK', |
|
| 440 | + 'MXN' => '$', |
|
| 441 | + 'MYR' => 'RM', |
|
| 442 | + 'MZN' => 'MT', |
|
| 443 | + 'NAD' => '$', |
|
| 444 | + 'NGN' => '₦', |
|
| 445 | + 'NIO' => 'C$', |
|
| 446 | + 'NOK' => 'kr', |
|
| 447 | + 'NPR' => '₨', |
|
| 448 | + 'NZD' => '$', |
|
| 449 | + 'OMR' => 'ر.ع.', |
|
| 450 | + 'PAB' => 'B/.', |
|
| 451 | + 'PEN' => 'S/.', |
|
| 452 | + 'PGK' => 'K', |
|
| 453 | + 'PHP' => '₱', |
|
| 454 | + 'PKR' => '₨', |
|
| 455 | + 'PLN' => 'zł', |
|
| 456 | + 'PRB' => 'р.', |
|
| 457 | + 'PYG' => '₲', |
|
| 458 | + 'QAR' => 'ر.ق', |
|
| 459 | + 'RMB' => '¥', |
|
| 460 | + 'RON' => 'lei', |
|
| 461 | + 'RSD' => 'дин.', |
|
| 462 | + 'RUB' => '₽', |
|
| 463 | + 'RWF' => 'Fr', |
|
| 464 | + 'SAR' => 'ر.س', |
|
| 465 | + 'SBD' => '$', |
|
| 466 | + 'SCR' => '₨', |
|
| 467 | + 'SDG' => 'ج.س.', |
|
| 468 | + 'SEK' => 'kr', |
|
| 469 | + 'SGD' => '$', |
|
| 470 | + 'SHP' => '£', |
|
| 471 | + 'SLL' => 'Le', |
|
| 472 | + 'SOS' => 'Sh', |
|
| 473 | + 'SRD' => '$', |
|
| 474 | + 'SSP' => '£', |
|
| 475 | + 'STD' => 'Db', |
|
| 476 | + 'SYP' => 'ل.س', |
|
| 477 | + 'SZL' => 'L', |
|
| 478 | + 'THB' => '฿', |
|
| 479 | + 'TJS' => 'ЅМ', |
|
| 480 | + 'TMT' => 'm', |
|
| 481 | + 'TND' => 'د.ت', |
|
| 482 | + 'TOP' => 'T$', |
|
| 483 | + 'TRY' => '₺', |
|
| 484 | + 'TTD' => '$', |
|
| 485 | + 'TWD' => 'NT$', |
|
| 486 | + 'TZS' => 'Sh', |
|
| 487 | + 'UAH' => '₴', |
|
| 488 | + 'UGX' => 'UGX', |
|
| 489 | + 'USD' => '$', |
|
| 490 | + 'UYU' => '$', |
|
| 491 | + 'UZS' => 'UZS', |
|
| 492 | + 'VEF' => 'Bs F', |
|
| 493 | + 'VND' => '₫', |
|
| 494 | + 'VUV' => 'Vt', |
|
| 495 | + 'WST' => 'T', |
|
| 496 | + 'XAF' => 'Fr', |
|
| 497 | + 'XCD' => '$', |
|
| 498 | + 'XOF' => 'Fr', |
|
| 499 | + 'XPF' => 'Fr', |
|
| 500 | + 'YER' => '﷼', |
|
| 501 | + 'ZAR' => 'R', |
|
| 502 | + 'ZMW' => 'ZK', |
|
| 503 | + ) ); |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + /** |
|
| 507 | + * Sanitize checkbox. |
|
| 508 | + * |
|
| 509 | + * @param $input html |
|
| 510 | + * @return mixed |
|
| 511 | + */ |
|
| 512 | + public function sanitize_checkbox( $input ) { |
|
| 513 | + return ( 1 === absint( $input ) ) ? 1 : 0; |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + /** |
|
| 517 | + * Sanitize select. |
|
| 518 | + * |
|
| 519 | + * @param $input html |
|
| 520 | + * @return mixed |
|
| 521 | + */ |
|
| 522 | + public function sanitize_select( $input ) { |
|
| 523 | + if ( is_string( $input ) || is_integer( $input ) || is_bool( $input ) ) { |
|
| 524 | + return $input; |
|
| 525 | + } else { |
|
| 526 | + return ''; |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + /** |
|
| 531 | + * Sanitize textarea. |
|
| 532 | + * |
|
| 533 | + * @param $input html |
|
| 534 | + * @return mixed |
|
| 535 | + */ |
|
| 536 | + public function sanitize_textarea( $input ) { |
|
| 537 | + return wp_kses_post( $input ); |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + /** |
|
| 541 | + * Migrate the old data (from UIX) to WP Customizer settings. |
|
| 542 | + * |
|
| 543 | + * @since 1.1.1 |
|
| 544 | + */ |
|
| 545 | + public function migration_uix_to_customize() { |
|
| 546 | + $visual_tab_migration = get_theme_mod( 'lsx_currencies_visual_tab_migration', false ); |
|
| 547 | + |
|
| 548 | + if ( empty( $visual_tab_migration ) ) { |
|
| 549 | + if ( isset( $this->options['display'] ) ) { |
|
| 550 | + if ( isset( $this->options['display']['currency_menu_switcher'] ) && is_array( $this->options['display']['currency_menu_switcher'] ) && ! empty( $this->options['display']['currency_menu_switcher'] ) ) { |
|
| 551 | + $currency_menu_position = $this->options['display']['currency_menu_switcher']; |
|
| 552 | + |
|
| 553 | + foreach ( $currency_menu_position as $key => $value ) { |
|
| 554 | + set_theme_mod( 'lsx_currencies_currency_menu_position', $key ); |
|
| 555 | + break; |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + if ( isset( $this->options['display']['display_flags'] ) && 'on' === $this->options['display']['display_flags'] ) { |
|
| 560 | + set_theme_mod( 'lsx_currencies_display_flags', true ); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + if ( isset( $this->options['display']['flag_position'] ) && 'on' === $this->options['display']['flag_position'] ) { |
|
| 564 | + set_theme_mod( 'lsx_currencies_flag_position', 'right' ); |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + if ( isset( $this->options['display']['currency_switcher_position'] ) && 'on' === $this->options['display']['currency_switcher_position'] ) { |
|
| 568 | + set_theme_mod( 'lsx_currencies_currency_switcher_position', 'left' ); |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + set_theme_mod( 'lsx_currencies_visual_tab_migration', true ); |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | 575 | } |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | * Constructor |
| 112 | 112 | */ |
| 113 | 113 | public function __construct() { |
| 114 | - add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); |
|
| 115 | - add_action( 'plugins_loaded', array( $this, 'set_defaults' ) ); |
|
| 114 | + add_action('plugins_loaded', array($this, 'plugins_loaded')); |
|
| 115 | + add_action('plugins_loaded', array($this, 'set_defaults')); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | public static function init() { |
| 124 | 124 | // If the single instance hasn't been set, set it now. |
| 125 | - if ( ! isset( self::$instance ) ) { |
|
| 125 | + if (!isset(self::$instance)) { |
|
| 126 | 126 | self::$instance = new self(); |
| 127 | 127 | } |
| 128 | 128 | return self::$instance; |
@@ -132,23 +132,23 @@ discard block |
||
| 132 | 132 | * After active plugins and pluggable functions are loaded |
| 133 | 133 | */ |
| 134 | 134 | public function plugins_loaded() { |
| 135 | - require_once LSX_CURRENCIES_PATH . 'classes/class-admin.php'; |
|
| 135 | + require_once LSX_CURRENCIES_PATH.'classes/class-admin.php'; |
|
| 136 | 136 | $this->admin = \lsx\currencies\classes\Admin::init(); |
| 137 | 137 | |
| 138 | - require_once LSX_CURRENCIES_PATH . 'classes/class-frontend.php'; |
|
| 138 | + require_once LSX_CURRENCIES_PATH.'classes/class-frontend.php'; |
|
| 139 | 139 | $this->frontend = \lsx\currencies\classes\Frontend::init(); |
| 140 | 140 | |
| 141 | - if ( class_exists( 'WooCommerce' ) ) { |
|
| 142 | - require_once LSX_CURRENCIES_PATH . 'classes/class-woocommerce.php'; |
|
| 141 | + if (class_exists('WooCommerce')) { |
|
| 142 | + require_once LSX_CURRENCIES_PATH.'classes/class-woocommerce.php'; |
|
| 143 | 143 | $this->woocommerce = \lsx\currencies\classes\WooCommerce::init(); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - if ( class_exists( 'FacetWP' ) ) { |
|
| 147 | - require_once LSX_CURRENCIES_PATH . 'classes/class-facetwp.php'; |
|
| 146 | + if (class_exists('FacetWP')) { |
|
| 147 | + require_once LSX_CURRENCIES_PATH.'classes/class-facetwp.php'; |
|
| 148 | 148 | $this->facetwp = \lsx\currencies\classes\FacetWP::init(); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - require_once LSX_CURRENCIES_PATH . '/includes/template-tags.php'; |
|
| 151 | + require_once LSX_CURRENCIES_PATH.'/includes/template-tags.php'; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -156,58 +156,58 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function set_defaults() { |
| 158 | 158 | $settings_tab = 'display'; |
| 159 | - if ( function_exists( 'tour_operator' ) ) { |
|
| 160 | - $options = get_option( '_lsx-to_settings', false ); |
|
| 159 | + if (function_exists('tour_operator')) { |
|
| 160 | + $options = get_option('_lsx-to_settings', false); |
|
| 161 | 161 | $settings_tab = 'general'; |
| 162 | 162 | } else { |
| 163 | - $options = get_option( '_lsx_settings', false ); |
|
| 163 | + $options = get_option('_lsx_settings', false); |
|
| 164 | 164 | |
| 165 | - if ( false === $options ) { |
|
| 166 | - $options = get_option( '_lsx_lsx-settings', false ); |
|
| 165 | + if (false === $options) { |
|
| 166 | + $options = get_option('_lsx_lsx-settings', false); |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - if ( false !== $options ) { |
|
| 170 | + if (false !== $options) { |
|
| 171 | 171 | $this->options = $options; |
| 172 | 172 | $this->migration_uix_to_customize(); |
| 173 | 173 | |
| 174 | - if ( isset( $this->options[ $settings_tab ] ) && isset( $this->options[ $settings_tab ]['currency'] ) ) { |
|
| 175 | - $this->base_currency = apply_filters( 'lsx_currencies_base_currency', $this->options[ $settings_tab ]['currency'], $this ); |
|
| 174 | + if (isset($this->options[$settings_tab]) && isset($this->options[$settings_tab]['currency'])) { |
|
| 175 | + $this->base_currency = apply_filters('lsx_currencies_base_currency', $this->options[$settings_tab]['currency'], $this); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ( isset( $this->options[ $settings_tab ]['additional_currencies'] ) && is_array( $this->options[ $settings_tab ]['additional_currencies'] ) && ! empty( $this->options[ $settings_tab ]['additional_currencies'] ) ) { |
|
| 179 | - $this->additional_currencies = $this->options[ $settings_tab ]['additional_currencies']; |
|
| 178 | + if (isset($this->options[$settings_tab]['additional_currencies']) && is_array($this->options[$settings_tab]['additional_currencies']) && !empty($this->options[$settings_tab]['additional_currencies'])) { |
|
| 179 | + $this->additional_currencies = $this->options[$settings_tab]['additional_currencies']; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - if ( isset( $this->options[ $settings_tab ]['multi_price'] ) && 'on' === $this->options[ $settings_tab ]['multi_price'] ) { |
|
| 182 | + if (isset($this->options[$settings_tab]['multi_price']) && 'on' === $this->options[$settings_tab]['multi_price']) { |
|
| 183 | 183 | $this->multi_prices = true; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - if ( isset( $this->options[ $settings_tab ]['convert_to_single_currency'] ) && 'on' === $this->options[ $settings_tab ]['convert_to_single_currency'] ) { |
|
| 186 | + if (isset($this->options[$settings_tab]['convert_to_single_currency']) && 'on' === $this->options[$settings_tab]['convert_to_single_currency']) { |
|
| 187 | 187 | $this->convert_to_single = true; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if ( isset( $this->options[ $settings_tab ]['remove_decimals'] ) && 'on' === $this->options[ $settings_tab ]['remove_decimals'] ) { |
|
| 190 | + if (isset($this->options[$settings_tab]['remove_decimals']) && 'on' === $this->options[$settings_tab]['remove_decimals']) { |
|
| 191 | 191 | $this->remove_decimals = true; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( isset( $this->options['api']['openexchange_api'] ) && '' !== $this->options['api']['openexchange_api'] ) { |
|
| 194 | + if (isset($this->options['api']['openexchange_api']) && '' !== $this->options['api']['openexchange_api']) { |
|
| 195 | 195 | $this->app_id = $this->options['api']['openexchange_api']; |
| 196 | - $this->api_url = 'http://openexchangerates.org/api/latest.json?app_id=' . $this->app_id; |
|
| 196 | + $this->api_url = 'http://openexchangerates.org/api/latest.json?app_id='.$this->app_id; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Currency Switcher Options. |
| 200 | - $this->menus = get_theme_mod( 'lsx_currencies_currency_menu_position', false ); |
|
| 200 | + $this->menus = get_theme_mod('lsx_currencies_currency_menu_position', false); |
|
| 201 | 201 | |
| 202 | - if ( get_theme_mod( 'lsx_currencies_display_flags', false ) ) { |
|
| 202 | + if (get_theme_mod('lsx_currencies_display_flags', false)) { |
|
| 203 | 203 | $this->display_flags = true; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if ( get_theme_mod( 'lsx_currencies_flag_position', false ) ) { |
|
| 206 | + if (get_theme_mod('lsx_currencies_flag_position', false)) { |
|
| 207 | 207 | $this->flag_position = 'right'; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - if ( get_theme_mod( 'lsx_currencies_currency_switcher_position', false ) ) { |
|
| 210 | + if (get_theme_mod('lsx_currencies_currency_switcher_position', false)) { |
|
| 211 | 211 | $this->switcher_symbol_position = 'left'; |
| 212 | 212 | } |
| 213 | 213 | } |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | * @param $key string |
| 223 | 223 | * @return string |
| 224 | 224 | */ |
| 225 | - public function get_currency_flag( $key = 'USD' ) { |
|
| 226 | - $key = strtoupper( $key ); |
|
| 227 | - return '<span class="flag-icon flag-icon-' . $this->flag_relations[ $key ] . '"></span> '; |
|
| 225 | + public function get_currency_flag($key = 'USD') { |
|
| 226 | + $key = strtoupper($key); |
|
| 227 | + return '<span class="flag-icon flag-icon-'.$this->flag_relations[$key].'"></span> '; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | * @param string $currency |
| 234 | 234 | * @return string |
| 235 | 235 | */ |
| 236 | - public function get_currency_symbol( $currency = '' ) { |
|
| 237 | - if ( ! $currency ) { |
|
| 236 | + public function get_currency_symbol($currency = '') { |
|
| 237 | + if (!$currency) { |
|
| 238 | 238 | $currency = $this->base_currency; |
| 239 | 239 | } |
| 240 | - $currency_symbol = isset( $this->currency_symbols[ $currency ] ) ? $this->currency_symbols[ $currency ] : ''; |
|
| 240 | + $currency_symbol = isset($this->currency_symbols[$currency]) ? $this->currency_symbols[$currency] : ''; |
|
| 241 | 241 | return $currency_symbol; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -249,43 +249,43 @@ discard block |
||
| 249 | 249 | public function get_available_currencies() { |
| 250 | 250 | |
| 251 | 251 | $paid_currencies = array( |
| 252 | - 'BWP' => esc_html__( 'Botswana Pula', 'lsx-currencies' ), |
|
| 253 | - 'KES' => esc_html__( 'Kenyan Shilling', 'lsx-currencies' ), |
|
| 254 | - 'LAK' => esc_html__( 'Laos Kip', 'lsx-currencies' ), |
|
| 255 | - 'MWK' => esc_html__( 'Malawian Kwacha', 'lsx-currencies' ), |
|
| 256 | - 'MZN' => esc_html__( 'Mozambique Metical', 'lsx-currencies' ), |
|
| 257 | - 'NAD' => esc_html__( 'Namibian Dollar', 'lsx-currencies' ), |
|
| 258 | - 'TZS' => esc_html__( 'Tanzania Shilling', 'lsx-currencies' ), |
|
| 259 | - 'AED' => esc_html__( 'United Arab Emirates Dirham', 'lsx-currencies' ), |
|
| 260 | - 'ZMW' => esc_html__( 'Zambian Kwacha', 'lsx-currencies' ), |
|
| 261 | - 'ZWL' => esc_html__( 'Zimbabwean Dollar', 'lsx-currencies' ), |
|
| 252 | + 'BWP' => esc_html__('Botswana Pula', 'lsx-currencies'), |
|
| 253 | + 'KES' => esc_html__('Kenyan Shilling', 'lsx-currencies'), |
|
| 254 | + 'LAK' => esc_html__('Laos Kip', 'lsx-currencies'), |
|
| 255 | + 'MWK' => esc_html__('Malawian Kwacha', 'lsx-currencies'), |
|
| 256 | + 'MZN' => esc_html__('Mozambique Metical', 'lsx-currencies'), |
|
| 257 | + 'NAD' => esc_html__('Namibian Dollar', 'lsx-currencies'), |
|
| 258 | + 'TZS' => esc_html__('Tanzania Shilling', 'lsx-currencies'), |
|
| 259 | + 'AED' => esc_html__('United Arab Emirates Dirham', 'lsx-currencies'), |
|
| 260 | + 'ZMW' => esc_html__('Zambian Kwacha', 'lsx-currencies'), |
|
| 261 | + 'ZWL' => esc_html__('Zimbabwean Dollar', 'lsx-currencies'), |
|
| 262 | 262 | ); |
| 263 | 263 | $free_currencies = array( |
| 264 | - 'AUD' => esc_html__( 'Australian Dollar', 'lsx-currencies' ), |
|
| 265 | - 'BRL' => esc_html__( 'Brazilian Real', 'lsx-currencies' ), |
|
| 266 | - 'GBP' => esc_html__( 'British Pound Sterling', 'lsx-currencies' ), |
|
| 267 | - 'CAD' => esc_html__( 'Canadian Dollar', 'lsx-currencies' ), |
|
| 268 | - 'CNY' => esc_html__( 'Chinese Yuan', 'lsx-currencies' ), |
|
| 269 | - 'EUR' => esc_html__( 'Euro', 'lsx-currencies' ), |
|
| 270 | - 'HKD' => esc_html__( 'Hong Kong Dollar', 'lsx-currencies' ), |
|
| 271 | - 'INR' => esc_html__( 'Indian Rupee', 'lsx-currencies' ), |
|
| 272 | - 'IDR' => esc_html__( 'Indonesia Rupiah', 'lsx-currencies' ), |
|
| 273 | - 'ILS' => esc_html__( 'Israeli Shekel', 'lsx-currencies' ), |
|
| 274 | - 'JPY' => esc_html__( 'Japanese Yen', 'lsx-currencies' ), |
|
| 275 | - 'MYR' => esc_html__( 'Malaysia Ringgit', 'lsx-currencies' ), |
|
| 276 | - 'NOK' => esc_html__( 'Norwegian Krone', 'lsx-currencies' ), |
|
| 277 | - 'NZD' => esc_html__( 'New Zealand Dollar', 'lsx-currencies' ), |
|
| 278 | - 'RUB' => esc_html__( 'Russian Ruble', 'lsx-currencies' ), |
|
| 279 | - 'SGD' => esc_html__( 'Singapore Dollar', 'lsx-currencies' ), |
|
| 280 | - 'ZAR' => esc_html__( 'South African Rand', 'lsx-currencies' ), |
|
| 281 | - 'SEK' => esc_html__( 'Swedish Krona', 'lsx-currencies' ), |
|
| 282 | - 'CHF' => esc_html__( 'Swiss Franc', 'lsx-currencies' ), |
|
| 283 | - 'USD' => esc_html__( 'United States Dollar', 'lsx-currencies' ), |
|
| 264 | + 'AUD' => esc_html__('Australian Dollar', 'lsx-currencies'), |
|
| 265 | + 'BRL' => esc_html__('Brazilian Real', 'lsx-currencies'), |
|
| 266 | + 'GBP' => esc_html__('British Pound Sterling', 'lsx-currencies'), |
|
| 267 | + 'CAD' => esc_html__('Canadian Dollar', 'lsx-currencies'), |
|
| 268 | + 'CNY' => esc_html__('Chinese Yuan', 'lsx-currencies'), |
|
| 269 | + 'EUR' => esc_html__('Euro', 'lsx-currencies'), |
|
| 270 | + 'HKD' => esc_html__('Hong Kong Dollar', 'lsx-currencies'), |
|
| 271 | + 'INR' => esc_html__('Indian Rupee', 'lsx-currencies'), |
|
| 272 | + 'IDR' => esc_html__('Indonesia Rupiah', 'lsx-currencies'), |
|
| 273 | + 'ILS' => esc_html__('Israeli Shekel', 'lsx-currencies'), |
|
| 274 | + 'JPY' => esc_html__('Japanese Yen', 'lsx-currencies'), |
|
| 275 | + 'MYR' => esc_html__('Malaysia Ringgit', 'lsx-currencies'), |
|
| 276 | + 'NOK' => esc_html__('Norwegian Krone', 'lsx-currencies'), |
|
| 277 | + 'NZD' => esc_html__('New Zealand Dollar', 'lsx-currencies'), |
|
| 278 | + 'RUB' => esc_html__('Russian Ruble', 'lsx-currencies'), |
|
| 279 | + 'SGD' => esc_html__('Singapore Dollar', 'lsx-currencies'), |
|
| 280 | + 'ZAR' => esc_html__('South African Rand', 'lsx-currencies'), |
|
| 281 | + 'SEK' => esc_html__('Swedish Krona', 'lsx-currencies'), |
|
| 282 | + 'CHF' => esc_html__('Swiss Franc', 'lsx-currencies'), |
|
| 283 | + 'USD' => esc_html__('United States Dollar', 'lsx-currencies'), |
|
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | - if ( false !== $this->app_id ) { |
|
| 287 | - $free_currencies = array_merge( $free_currencies, $paid_currencies ); |
|
| 288 | - asort( $free_currencies ); |
|
| 286 | + if (false !== $this->app_id) { |
|
| 287 | + $free_currencies = array_merge($free_currencies, $paid_currencies); |
|
| 288 | + asort($free_currencies); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | return $free_currencies; |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | * @return array |
| 338 | 338 | */ |
| 339 | 339 | public function get_currency_symbols() { |
| 340 | - return apply_filters( 'lsx_currencies_symbols', array( |
|
| 340 | + return apply_filters('lsx_currencies_symbols', array( |
|
| 341 | 341 | 'AED' => 'د.إ', |
| 342 | 342 | 'AFN' => '؋', |
| 343 | 343 | 'ALL' => 'L', |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | 'YER' => '﷼', |
| 501 | 501 | 'ZAR' => 'R', |
| 502 | 502 | 'ZMW' => 'ZK', |
| 503 | - ) ); |
|
| 503 | + )); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
@@ -509,8 +509,8 @@ discard block |
||
| 509 | 509 | * @param $input html |
| 510 | 510 | * @return mixed |
| 511 | 511 | */ |
| 512 | - public function sanitize_checkbox( $input ) { |
|
| 513 | - return ( 1 === absint( $input ) ) ? 1 : 0; |
|
| 512 | + public function sanitize_checkbox($input) { |
|
| 513 | + return (1 === absint($input)) ? 1 : 0; |
|
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | /** |
@@ -519,8 +519,8 @@ discard block |
||
| 519 | 519 | * @param $input html |
| 520 | 520 | * @return mixed |
| 521 | 521 | */ |
| 522 | - public function sanitize_select( $input ) { |
|
| 523 | - if ( is_string( $input ) || is_integer( $input ) || is_bool( $input ) ) { |
|
| 522 | + public function sanitize_select($input) { |
|
| 523 | + if (is_string($input) || is_integer($input) || is_bool($input)) { |
|
| 524 | 524 | return $input; |
| 525 | 525 | } else { |
| 526 | 526 | return ''; |
@@ -533,8 +533,8 @@ discard block |
||
| 533 | 533 | * @param $input html |
| 534 | 534 | * @return mixed |
| 535 | 535 | */ |
| 536 | - public function sanitize_textarea( $input ) { |
|
| 537 | - return wp_kses_post( $input ); |
|
| 536 | + public function sanitize_textarea($input) { |
|
| 537 | + return wp_kses_post($input); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /** |
@@ -543,33 +543,33 @@ discard block |
||
| 543 | 543 | * @since 1.1.1 |
| 544 | 544 | */ |
| 545 | 545 | public function migration_uix_to_customize() { |
| 546 | - $visual_tab_migration = get_theme_mod( 'lsx_currencies_visual_tab_migration', false ); |
|
| 546 | + $visual_tab_migration = get_theme_mod('lsx_currencies_visual_tab_migration', false); |
|
| 547 | 547 | |
| 548 | - if ( empty( $visual_tab_migration ) ) { |
|
| 549 | - if ( isset( $this->options['display'] ) ) { |
|
| 550 | - if ( isset( $this->options['display']['currency_menu_switcher'] ) && is_array( $this->options['display']['currency_menu_switcher'] ) && ! empty( $this->options['display']['currency_menu_switcher'] ) ) { |
|
| 548 | + if (empty($visual_tab_migration)) { |
|
| 549 | + if (isset($this->options['display'])) { |
|
| 550 | + if (isset($this->options['display']['currency_menu_switcher']) && is_array($this->options['display']['currency_menu_switcher']) && !empty($this->options['display']['currency_menu_switcher'])) { |
|
| 551 | 551 | $currency_menu_position = $this->options['display']['currency_menu_switcher']; |
| 552 | 552 | |
| 553 | - foreach ( $currency_menu_position as $key => $value ) { |
|
| 554 | - set_theme_mod( 'lsx_currencies_currency_menu_position', $key ); |
|
| 553 | + foreach ($currency_menu_position as $key => $value) { |
|
| 554 | + set_theme_mod('lsx_currencies_currency_menu_position', $key); |
|
| 555 | 555 | break; |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - if ( isset( $this->options['display']['display_flags'] ) && 'on' === $this->options['display']['display_flags'] ) { |
|
| 560 | - set_theme_mod( 'lsx_currencies_display_flags', true ); |
|
| 559 | + if (isset($this->options['display']['display_flags']) && 'on' === $this->options['display']['display_flags']) { |
|
| 560 | + set_theme_mod('lsx_currencies_display_flags', true); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - if ( isset( $this->options['display']['flag_position'] ) && 'on' === $this->options['display']['flag_position'] ) { |
|
| 564 | - set_theme_mod( 'lsx_currencies_flag_position', 'right' ); |
|
| 563 | + if (isset($this->options['display']['flag_position']) && 'on' === $this->options['display']['flag_position']) { |
|
| 564 | + set_theme_mod('lsx_currencies_flag_position', 'right'); |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - if ( isset( $this->options['display']['currency_switcher_position'] ) && 'on' === $this->options['display']['currency_switcher_position'] ) { |
|
| 568 | - set_theme_mod( 'lsx_currencies_currency_switcher_position', 'left' ); |
|
| 567 | + if (isset($this->options['display']['currency_switcher_position']) && 'on' === $this->options['display']['currency_switcher_position']) { |
|
| 568 | + set_theme_mod('lsx_currencies_currency_switcher_position', 'left'); |
|
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - set_theme_mod( 'lsx_currencies_visual_tab_migration', true ); |
|
| 572 | + set_theme_mod('lsx_currencies_visual_tab_migration', true); |
|
| 573 | 573 | } |
| 574 | 574 | } |
| 575 | 575 | } |
@@ -16,80 +16,80 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class WooCommerce { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Holds instance of the class |
|
| 21 | - * |
|
| 22 | - * @var object \lsx\currencies\classes\WooCommerce() |
|
| 23 | - */ |
|
| 24 | - private static $instance; |
|
| 19 | + /** |
|
| 20 | + * Holds instance of the class |
|
| 21 | + * |
|
| 22 | + * @var object \lsx\currencies\classes\WooCommerce() |
|
| 23 | + */ |
|
| 24 | + private static $instance; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Holds the current currency. |
|
| 28 | - * |
|
| 29 | - * @var boolean |
|
| 30 | - */ |
|
| 31 | - public $currency = false; |
|
| 26 | + /** |
|
| 27 | + * Holds the current currency. |
|
| 28 | + * |
|
| 29 | + * @var boolean |
|
| 30 | + */ |
|
| 31 | + public $currency = false; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor |
|
| 35 | - */ |
|
| 36 | - public function __construct() { |
|
| 37 | - add_filter( 'wc_price', array( $this, 'price_filter' ), 300, 3 ); |
|
| 38 | - add_filter( 'lsx_currencies_base_currency', array( $this, 'set_base_currency' ), 10, 1 ); |
|
| 39 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor |
|
| 35 | + */ |
|
| 36 | + public function __construct() { |
|
| 37 | + add_filter( 'wc_price', array( $this, 'price_filter' ), 300, 3 ); |
|
| 38 | + add_filter( 'lsx_currencies_base_currency', array( $this, 'set_base_currency' ), 10, 1 ); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Return an instance of this class. |
|
| 43 | - * |
|
| 44 | - * @return object |
|
| 45 | - */ |
|
| 46 | - public static function init() { |
|
| 47 | - // If the single instance hasn't been set, set it now. |
|
| 48 | - if ( ! isset( self::$instance ) ) { |
|
| 49 | - self::$instance = new self(); |
|
| 50 | - } |
|
| 51 | - return self::$instance; |
|
| 52 | - } |
|
| 41 | + /** |
|
| 42 | + * Return an instance of this class. |
|
| 43 | + * |
|
| 44 | + * @return object |
|
| 45 | + */ |
|
| 46 | + public static function init() { |
|
| 47 | + // If the single instance hasn't been set, set it now. |
|
| 48 | + if ( ! isset( self::$instance ) ) { |
|
| 49 | + self::$instance = new self(); |
|
| 50 | + } |
|
| 51 | + return self::$instance; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Filter the WooCommerce Price. |
|
| 56 | - * |
|
| 57 | - * @param $return mixed |
|
| 58 | - * @param $price string |
|
| 59 | - * @param $args array |
|
| 60 | - * |
|
| 61 | - * @return mixed |
|
| 62 | - */ |
|
| 63 | - public function price_filter( $return, $price, $args ) { |
|
| 64 | - if ( '' !== $price ) { |
|
| 65 | - $return = str_replace( 'class', 'data-price-' . lsx_currencies()->base_currency . '=' . $price . ' class', $return ); |
|
| 66 | - $return = str_replace( 'woocommerce-Price-amount', 'woocommerce-Price-amount lsx-currencies', $return ); |
|
| 67 | - } |
|
| 68 | - return $return; |
|
| 69 | - } |
|
| 54 | + /** |
|
| 55 | + * Filter the WooCommerce Price. |
|
| 56 | + * |
|
| 57 | + * @param $return mixed |
|
| 58 | + * @param $price string |
|
| 59 | + * @param $args array |
|
| 60 | + * |
|
| 61 | + * @return mixed |
|
| 62 | + */ |
|
| 63 | + public function price_filter( $return, $price, $args ) { |
|
| 64 | + if ( '' !== $price ) { |
|
| 65 | + $return = str_replace( 'class', 'data-price-' . lsx_currencies()->base_currency . '=' . $price . ' class', $return ); |
|
| 66 | + $return = str_replace( 'woocommerce-Price-amount', 'woocommerce-Price-amount lsx-currencies', $return ); |
|
| 67 | + } |
|
| 68 | + return $return; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @param $cart_subtotal |
|
| 73 | - * @param $compound |
|
| 74 | - * @param $obj |
|
| 75 | - * |
|
| 76 | - * @return mixed |
|
| 77 | - */ |
|
| 78 | - public function cart_subtotal( $cart_subtotal, $compound, $obj ) { |
|
| 71 | + /** |
|
| 72 | + * @param $cart_subtotal |
|
| 73 | + * @param $compound |
|
| 74 | + * @param $obj |
|
| 75 | + * |
|
| 76 | + * @return mixed |
|
| 77 | + */ |
|
| 78 | + public function cart_subtotal( $cart_subtotal, $compound, $obj ) { |
|
| 79 | 79 | |
| 80 | - $return = str_replace( 'class', 'data-price-' . $this->currency . '=' . $price . ' class', $return ); |
|
| 81 | - $return = str_replace( 'woocommerce-Price-amount', 'woocommerce-Price-amount lsx-currencies', $return ); |
|
| 80 | + $return = str_replace( 'class', 'data-price-' . $this->currency . '=' . $price . ' class', $return ); |
|
| 81 | + $return = str_replace( 'woocommerce-Price-amount', 'woocommerce-Price-amount lsx-currencies', $return ); |
|
| 82 | 82 | |
| 83 | - return $cart_subtotal; |
|
| 84 | - } |
|
| 83 | + return $cart_subtotal; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Make sure our base currency is set to the same as woocommerce. |
|
| 88 | - * |
|
| 89 | - * @param string $currency |
|
| 90 | - * @return void |
|
| 91 | - */ |
|
| 92 | - public function set_base_currency( $currency ) { |
|
| 93 | - return get_woocommerce_currency(); |
|
| 94 | - } |
|
| 86 | + /** |
|
| 87 | + * Make sure our base currency is set to the same as woocommerce. |
|
| 88 | + * |
|
| 89 | + * @param string $currency |
|
| 90 | + * @return void |
|
| 91 | + */ |
|
| 92 | + public function set_base_currency( $currency ) { |
|
| 93 | + return get_woocommerce_currency(); |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * Constructor |
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | - add_filter( 'wc_price', array( $this, 'price_filter' ), 300, 3 ); |
|
| 38 | - add_filter( 'lsx_currencies_base_currency', array( $this, 'set_base_currency' ), 10, 1 ); |
|
| 37 | + add_filter('wc_price', array($this, 'price_filter'), 300, 3); |
|
| 38 | + add_filter('lsx_currencies_base_currency', array($this, 'set_base_currency'), 10, 1); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public static function init() { |
| 47 | 47 | // If the single instance hasn't been set, set it now. |
| 48 | - if ( ! isset( self::$instance ) ) { |
|
| 48 | + if (!isset(self::$instance)) { |
|
| 49 | 49 | self::$instance = new self(); |
| 50 | 50 | } |
| 51 | 51 | return self::$instance; |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return mixed |
| 62 | 62 | */ |
| 63 | - public function price_filter( $return, $price, $args ) { |
|
| 64 | - if ( '' !== $price ) { |
|
| 65 | - $return = str_replace( 'class', 'data-price-' . lsx_currencies()->base_currency . '=' . $price . ' class', $return ); |
|
| 66 | - $return = str_replace( 'woocommerce-Price-amount', 'woocommerce-Price-amount lsx-currencies', $return ); |
|
| 63 | + public function price_filter($return, $price, $args) { |
|
| 64 | + if ('' !== $price) { |
|
| 65 | + $return = str_replace('class', 'data-price-'.lsx_currencies()->base_currency.'='.$price.' class', $return); |
|
| 66 | + $return = str_replace('woocommerce-Price-amount', 'woocommerce-Price-amount lsx-currencies', $return); |
|
| 67 | 67 | } |
| 68 | 68 | return $return; |
| 69 | 69 | } |
@@ -75,10 +75,10 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return mixed |
| 77 | 77 | */ |
| 78 | - public function cart_subtotal( $cart_subtotal, $compound, $obj ) { |
|
| 78 | + public function cart_subtotal($cart_subtotal, $compound, $obj) { |
|
| 79 | 79 | |
| 80 | - $return = str_replace( 'class', 'data-price-' . $this->currency . '=' . $price . ' class', $return ); |
|
| 81 | - $return = str_replace( 'woocommerce-Price-amount', 'woocommerce-Price-amount lsx-currencies', $return ); |
|
| 80 | + $return = str_replace('class', 'data-price-'.$this->currency.'='.$price.' class', $return); |
|
| 81 | + $return = str_replace('woocommerce-Price-amount', 'woocommerce-Price-amount lsx-currencies', $return); |
|
| 82 | 82 | |
| 83 | 83 | return $cart_subtotal; |
| 84 | 84 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param string $currency |
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | - public function set_base_currency( $currency ) { |
|
| 92 | + public function set_base_currency($currency) { |
|
| 93 | 93 | return get_woocommerce_currency(); |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -1,147 +1,147 @@ |
||
| 1 | 1 | <div class="uix-field-wrapper"> |
| 2 | 2 | <ul class="ui-tab-nav"> |
| 3 | - <?php if ( class_exists( 'LSX_Banners' ) ) { ?> |
|
| 4 | - <li><a href="#ui-placeholders" class="active"><?php esc_html_e( 'Placeholders', 'lsx-currencies' ); ?></a></li> |
|
| 3 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
| 4 | + <li><a href="#ui-placeholders" class="active"><?php esc_html_e('Placeholders', 'lsx-currencies'); ?></a></li> |
|
| 5 | 5 | <?php } ?> |
| 6 | 6 | |
| 7 | - <?php if ( class_exists( 'LSX_Currencies' ) ) { ?> |
|
| 8 | - <?php $class_active = class_exists( 'LSX_Banners' ) ? '' : 'active'; ?> |
|
| 9 | - <li><a href="#ui-currencies" class="<?php echo esc_attr( $class_active ); ?>"><?php esc_html_e( 'Currencies', 'lsx-currencies' ); ?></a></li> |
|
| 7 | + <?php if (class_exists('LSX_Currencies')) { ?> |
|
| 8 | + <?php $class_active = class_exists('LSX_Banners') ? '' : 'active'; ?> |
|
| 9 | + <li><a href="#ui-currencies" class="<?php echo esc_attr($class_active); ?>"><?php esc_html_e('Currencies', 'lsx-currencies'); ?></a></li> |
|
| 10 | 10 | <?php } ?> |
| 11 | 11 | |
| 12 | - <?php if ( class_exists( 'LSX_Team' ) ) { ?> |
|
| 13 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) ) ? '' : 'active'; ?> |
|
| 14 | - <li><a href="#ui-team" class="<?php echo esc_attr( $class_active ); ?>"><?php esc_html_e( 'Team', 'lsx-currencies' ); ?></a></li> |
|
| 12 | + <?php if (class_exists('LSX_Team')) { ?> |
|
| 13 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies')) ? '' : 'active'; ?> |
|
| 14 | + <li><a href="#ui-team" class="<?php echo esc_attr($class_active); ?>"><?php esc_html_e('Team', 'lsx-currencies'); ?></a></li> |
|
| 15 | 15 | <?php } ?> |
| 16 | 16 | |
| 17 | - <?php if ( class_exists( 'LSX_Testimonials' ) ) { ?> |
|
| 18 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) ) ? '' : 'active'; ?> |
|
| 19 | - <li><a href="#ui-testimonials" class="<?php echo esc_attr( $class_active ); ?>"><?php esc_html_e( 'Testimonials', 'lsx-currencies' ); ?></a></li> |
|
| 17 | + <?php if (class_exists('LSX_Testimonials')) { ?> |
|
| 18 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team')) ? '' : 'active'; ?> |
|
| 19 | + <li><a href="#ui-testimonials" class="<?php echo esc_attr($class_active); ?>"><?php esc_html_e('Testimonials', 'lsx-currencies'); ?></a></li> |
|
| 20 | 20 | <?php } ?> |
| 21 | 21 | |
| 22 | - <?php if ( class_exists( 'LSX_Projects' ) ) { ?> |
|
| 23 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) ) ? '' : 'active'; ?> |
|
| 24 | - <li><a href="#ui-projects" class="<?php echo esc_attr( $class_active ); ?>"><?php esc_html_e( 'Projects', 'lsx-currencies' ); ?></a></li> |
|
| 22 | + <?php if (class_exists('LSX_Projects')) { ?> |
|
| 23 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials')) ? '' : 'active'; ?> |
|
| 24 | + <li><a href="#ui-projects" class="<?php echo esc_attr($class_active); ?>"><?php esc_html_e('Projects', 'lsx-currencies'); ?></a></li> |
|
| 25 | 25 | <?php } ?> |
| 26 | 26 | |
| 27 | - <?php if ( class_exists( 'LSX_Services' ) ) { ?> |
|
| 28 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) || class_exists( 'LSX_Projects' ) ) ? '' : 'active'; ?> |
|
| 29 | - <li><a href="#ui-services" class="<?php echo esc_attr( $class ); ?>"><?php esc_html_e( 'Services', 'lsx-currencies' ); ?></a></li> |
|
| 27 | + <?php if (class_exists('LSX_Services')) { ?> |
|
| 28 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials') || class_exists('LSX_Projects')) ? '' : 'active'; ?> |
|
| 29 | + <li><a href="#ui-services" class="<?php echo esc_attr($class); ?>"><?php esc_html_e('Services', 'lsx-currencies'); ?></a></li> |
|
| 30 | 30 | <?php $class = ''; } ?> |
| 31 | 31 | |
| 32 | - <?php if ( class_exists( 'LSX_Blog_Customizer' ) ) { ?> |
|
| 33 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) || class_exists( 'LSX_Projects' ) || class_exists( 'LSX_Services' ) ) ? '' : 'active'; ?> |
|
| 34 | - <li><a href="#ui-blog-customizer" class="<?php echo esc_attr( $class_active ); ?>"><?php esc_html_e( 'Blog Customizer (posts widget)', 'lsx-currencies' ); ?></a></li> |
|
| 32 | + <?php if (class_exists('LSX_Blog_Customizer')) { ?> |
|
| 33 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials') || class_exists('LSX_Projects') || class_exists('LSX_Services')) ? '' : 'active'; ?> |
|
| 34 | + <li><a href="#ui-blog-customizer" class="<?php echo esc_attr($class_active); ?>"><?php esc_html_e('Blog Customizer (posts widget)', 'lsx-currencies'); ?></a></li> |
|
| 35 | 35 | <?php } ?> |
| 36 | 36 | |
| 37 | - <?php if ( class_exists( 'LSX_Sharing' ) ) { ?> |
|
| 38 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) || class_exists( 'LSX_Projects' ) || class_exists( 'LSX_Services' ) || class_exists( 'LSX_Blog_Customizer' ) ) ? '' : 'active'; ?> |
|
| 39 | - <li><a href="#ui-sharing" class="<?php echo esc_attr( $class_active ); ?>"><?php esc_html_e( 'Sharing', 'lsx-currencies' ); ?></a></li> |
|
| 37 | + <?php if (class_exists('LSX_Sharing')) { ?> |
|
| 38 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials') || class_exists('LSX_Projects') || class_exists('LSX_Services') || class_exists('LSX_Blog_Customizer')) ? '' : 'active'; ?> |
|
| 39 | + <li><a href="#ui-sharing" class="<?php echo esc_attr($class_active); ?>"><?php esc_html_e('Sharing', 'lsx-currencies'); ?></a></li> |
|
| 40 | 40 | <?php } ?> |
| 41 | 41 | |
| 42 | - <?php if ( class_exists( 'LSX_Videos' ) ) { ?> |
|
| 43 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) || class_exists( 'LSX_Projects' ) || class_exists( 'LSX_Services' ) || class_exists( 'LSX_Blog_Customizer' ) || class_exists( 'LSX_Sharing' ) ) ? '' : 'active'; ?> |
|
| 44 | - <li><a href="#ui-videos" class="<?php echo esc_attr( $class_active ); ?>"><?php esc_html_e( 'Videos', 'lsx-currencies' ); ?></a></li> |
|
| 42 | + <?php if (class_exists('LSX_Videos')) { ?> |
|
| 43 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials') || class_exists('LSX_Projects') || class_exists('LSX_Services') || class_exists('LSX_Blog_Customizer') || class_exists('LSX_Sharing')) ? '' : 'active'; ?> |
|
| 44 | + <li><a href="#ui-videos" class="<?php echo esc_attr($class_active); ?>"><?php esc_html_e('Videos', 'lsx-currencies'); ?></a></li> |
|
| 45 | 45 | <?php } ?> |
| 46 | 46 | </ul> |
| 47 | 47 | |
| 48 | - <?php if ( class_exists( 'LSX_Banners' ) ) { ?> |
|
| 48 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
| 49 | 49 | <div id="ui-placeholders" class="ui-tab active"> |
| 50 | 50 | <table class="form-table"> |
| 51 | 51 | <tbody> |
| 52 | - <?php do_action( 'lsx_framework_display_tab_content', 'placeholders' ); ?> |
|
| 52 | + <?php do_action('lsx_framework_display_tab_content', 'placeholders'); ?> |
|
| 53 | 53 | </tbody> |
| 54 | 54 | </table> |
| 55 | 55 | </div> |
| 56 | 56 | <?php } ?> |
| 57 | 57 | |
| 58 | - <?php if ( class_exists( 'LSX_Currencies' ) ) { ?> |
|
| 59 | - <?php $class_active = class_exists( 'LSX_Banners' ) ? '' : 'active'; ?> |
|
| 60 | - <div id="ui-currencies" class="ui-tab <?php echo esc_attr( $class_active ); ?>"> |
|
| 58 | + <?php if (class_exists('LSX_Currencies')) { ?> |
|
| 59 | + <?php $class_active = class_exists('LSX_Banners') ? '' : 'active'; ?> |
|
| 60 | + <div id="ui-currencies" class="ui-tab <?php echo esc_attr($class_active); ?>"> |
|
| 61 | 61 | <table class="form-table"> |
| 62 | 62 | <tbody> |
| 63 | - <?php do_action( 'lsx_framework_display_tab_content', 'currency_switcher' ); ?> |
|
| 63 | + <?php do_action('lsx_framework_display_tab_content', 'currency_switcher'); ?> |
|
| 64 | 64 | </tbody> |
| 65 | 65 | </table> |
| 66 | 66 | </div> |
| 67 | 67 | <?php } ?> |
| 68 | 68 | |
| 69 | - <?php if ( class_exists( 'LSX_Team' ) ) { ?> |
|
| 70 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) ) ? '' : 'active'; ?> |
|
| 71 | - <div id="ui-team" class="ui-tab <?php echo esc_attr( $class_active ); ?>"> |
|
| 69 | + <?php if (class_exists('LSX_Team')) { ?> |
|
| 70 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies')) ? '' : 'active'; ?> |
|
| 71 | + <div id="ui-team" class="ui-tab <?php echo esc_attr($class_active); ?>"> |
|
| 72 | 72 | <table class="form-table"> |
| 73 | 73 | <tbody> |
| 74 | - <?php do_action( 'lsx_framework_display_tab_content', 'team' ); ?> |
|
| 74 | + <?php do_action('lsx_framework_display_tab_content', 'team'); ?> |
|
| 75 | 75 | </tbody> |
| 76 | 76 | </table> |
| 77 | 77 | </div> |
| 78 | 78 | <?php } ?> |
| 79 | 79 | |
| 80 | - <?php if ( class_exists( 'LSX_Testimonials' ) ) { ?> |
|
| 81 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) ) ? '' : 'active'; ?> |
|
| 82 | - <div id="ui-testimonials" class="ui-tab <?php echo esc_attr( $class_active ); ?>"> |
|
| 80 | + <?php if (class_exists('LSX_Testimonials')) { ?> |
|
| 81 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team')) ? '' : 'active'; ?> |
|
| 82 | + <div id="ui-testimonials" class="ui-tab <?php echo esc_attr($class_active); ?>"> |
|
| 83 | 83 | <table class="form-table"> |
| 84 | 84 | <tbody> |
| 85 | - <?php do_action( 'lsx_framework_display_tab_content', 'testimonials' ); ?> |
|
| 85 | + <?php do_action('lsx_framework_display_tab_content', 'testimonials'); ?> |
|
| 86 | 86 | </tbody> |
| 87 | 87 | </table> |
| 88 | 88 | </div> |
| 89 | 89 | <?php } ?> |
| 90 | 90 | |
| 91 | - <?php if ( class_exists( 'LSX_Projects' ) ) { ?> |
|
| 92 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) ) ? '' : 'active'; ?> |
|
| 93 | - <div id="ui-projects" class="ui-tab <?php echo esc_attr( $class_active ); ?>"> |
|
| 91 | + <?php if (class_exists('LSX_Projects')) { ?> |
|
| 92 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials')) ? '' : 'active'; ?> |
|
| 93 | + <div id="ui-projects" class="ui-tab <?php echo esc_attr($class_active); ?>"> |
|
| 94 | 94 | <table class="form-table"> |
| 95 | 95 | <tbody> |
| 96 | - <?php do_action( 'lsx_framework_display_tab_content', 'projects' ); ?> |
|
| 96 | + <?php do_action('lsx_framework_display_tab_content', 'projects'); ?> |
|
| 97 | 97 | </tbody> |
| 98 | 98 | </table> |
| 99 | 99 | </div> |
| 100 | 100 | <?php } ?> |
| 101 | 101 | |
| 102 | - <?php if ( class_exists( 'LSX_Services' ) ) { ?> |
|
| 103 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) || class_exists( 'LSX_Projects' ) ) ? '' : 'active'; ?> |
|
| 104 | - <div id="ui-services" class="ui-tab <?php echo esc_attr( $class_active ); ?>"> |
|
| 102 | + <?php if (class_exists('LSX_Services')) { ?> |
|
| 103 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials') || class_exists('LSX_Projects')) ? '' : 'active'; ?> |
|
| 104 | + <div id="ui-services" class="ui-tab <?php echo esc_attr($class_active); ?>"> |
|
| 105 | 105 | <table class="form-table"> |
| 106 | 106 | <tbody> |
| 107 | - <?php do_action( 'lsx_framework_display_tab_content', 'services' ); ?> |
|
| 107 | + <?php do_action('lsx_framework_display_tab_content', 'services'); ?> |
|
| 108 | 108 | </tbody> |
| 109 | 109 | </table> |
| 110 | 110 | </div> |
| 111 | 111 | <?php } ?> |
| 112 | 112 | |
| 113 | - <?php if ( class_exists( 'LSX_Blog_Customizer' ) ) { ?> |
|
| 114 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) || class_exists( 'LSX_Projects' ) || class_exists( 'LSX_Services' ) ) ? '' : 'active'; ?> |
|
| 115 | - <div id="ui-blog-customizer" class="ui-tab <?php echo esc_attr( $class_active ); ?>"> |
|
| 113 | + <?php if (class_exists('LSX_Blog_Customizer')) { ?> |
|
| 114 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials') || class_exists('LSX_Projects') || class_exists('LSX_Services')) ? '' : 'active'; ?> |
|
| 115 | + <div id="ui-blog-customizer" class="ui-tab <?php echo esc_attr($class_active); ?>"> |
|
| 116 | 116 | <table class="form-table"> |
| 117 | 117 | <tbody> |
| 118 | - <?php do_action( 'lsx_framework_display_tab_content', 'blog-customizer' ); ?> |
|
| 118 | + <?php do_action('lsx_framework_display_tab_content', 'blog-customizer'); ?> |
|
| 119 | 119 | </tbody> |
| 120 | 120 | </table> |
| 121 | 121 | </div> |
| 122 | 122 | <?php } ?> |
| 123 | 123 | |
| 124 | - <?php if ( class_exists( 'LSX_Sharing' ) ) { ?> |
|
| 125 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) || class_exists( 'LSX_Projects' ) || class_exists( 'LSX_Services' ) || class_exists( 'LSX_Blog_Customizer' ) ) ? '' : 'active'; ?> |
|
| 126 | - <div id="ui-sharing" class="ui-tab <?php echo esc_attr( $class_active ); ?>"> |
|
| 124 | + <?php if (class_exists('LSX_Sharing')) { ?> |
|
| 125 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials') || class_exists('LSX_Projects') || class_exists('LSX_Services') || class_exists('LSX_Blog_Customizer')) ? '' : 'active'; ?> |
|
| 126 | + <div id="ui-sharing" class="ui-tab <?php echo esc_attr($class_active); ?>"> |
|
| 127 | 127 | <table class="form-table"> |
| 128 | 128 | <tbody> |
| 129 | - <?php do_action( 'lsx_framework_display_tab_content', 'sharing' ); ?> |
|
| 129 | + <?php do_action('lsx_framework_display_tab_content', 'sharing'); ?> |
|
| 130 | 130 | </tbody> |
| 131 | 131 | </table> |
| 132 | 132 | </div> |
| 133 | 133 | <?php } ?> |
| 134 | 134 | |
| 135 | - <?php if ( class_exists( 'LSX_Videos' ) ) { ?> |
|
| 136 | - <?php $class_active = ( class_exists( 'LSX_Banners' ) || class_exists( 'LSX_Currencies' ) || class_exists( 'LSX_Team' ) || class_exists( 'LSX_Testimonials' ) || class_exists( 'LSX_Projects' ) || class_exists( 'LSX_Services' ) || class_exists( 'LSX_Blog_Customizer' ) || class_exists( 'LSX_Sharing' ) ) ? '' : 'active'; ?> |
|
| 137 | - <div id="ui-videos" class="ui-tab <?php echo esc_attr( $class_active ); ?>"> |
|
| 135 | + <?php if (class_exists('LSX_Videos')) { ?> |
|
| 136 | + <?php $class_active = (class_exists('LSX_Banners') || class_exists('LSX_Currencies') || class_exists('LSX_Team') || class_exists('LSX_Testimonials') || class_exists('LSX_Projects') || class_exists('LSX_Services') || class_exists('LSX_Blog_Customizer') || class_exists('LSX_Sharing')) ? '' : 'active'; ?> |
|
| 137 | + <div id="ui-videos" class="ui-tab <?php echo esc_attr($class_active); ?>"> |
|
| 138 | 138 | <table class="form-table"> |
| 139 | 139 | <tbody> |
| 140 | - <?php do_action( 'lsx_framework_display_tab_content', 'videos' ); ?> |
|
| 140 | + <?php do_action('lsx_framework_display_tab_content', 'videos'); ?> |
|
| 141 | 141 | </tbody> |
| 142 | 142 | </table> |
| 143 | 143 | </div> |
| 144 | 144 | <?php } ?> |
| 145 | 145 | |
| 146 | - <?php do_action( 'lsx_framework_display_tab_bottom', 'display' ); ?> |
|
| 146 | + <?php do_action('lsx_framework_display_tab_bottom', 'display'); ?> |
|
| 147 | 147 | </div> |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <div class="uix-field-wrapper"> |
| 2 | 2 | <?php |
| 3 | - $display_settings_page = false; |
|
| 3 | + $display_settings_page = false; |
|
| 4 | 4 | |
| 5 | - if ( class_exists( 'LSX_Currencies' ) ) { |
|
| 6 | - $display_settings_page = true; |
|
| 7 | - } |
|
| 8 | - ?> |
|
| 5 | + if ( class_exists( 'LSX_Currencies' ) ) { |
|
| 6 | + $display_settings_page = true; |
|
| 7 | + } |
|
| 8 | + ?> |
|
| 9 | 9 | |
| 10 | 10 | <ul class="ui-tab-nav"> |
| 11 | 11 | <?php |
| 12 | - if ( false !== $display_settings_page ) { |
|
| 12 | + if ( false !== $display_settings_page ) { |
|
| 13 | 13 | ?> |
| 14 | 14 | <li><a href="#ui-settings" class="active"><?php esc_html_e( 'Settings', 'lsx-currencies' ); ?></a></li><?php } ?> |
| 15 | 15 | <li><a href="#ui-keys" |
| 16 | 16 | <?php |
| 17 | - if ( false === $display_settings_page ) { |
|
| 17 | + if ( false === $display_settings_page ) { |
|
| 18 | 18 | ?> |
| 19 | 19 | class="active"<?php } ?>><?php esc_html_e( 'License Keys', 'lsx-currencies' ); ?></a></li> |
| 20 | 20 | </ul> |
@@ -33,25 +33,25 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | <div id="ui-keys" class="ui-tab |
| 35 | 35 | <?php |
| 36 | - if ( false === $display_settings_page ) { |
|
| 36 | + if ( false === $display_settings_page ) { |
|
| 37 | 37 | ?> |
| 38 | 38 | active<?php } ?>"> |
| 39 | 39 | <table class="form-table" style="margin-top:-13px !important;"> |
| 40 | 40 | <tbody> |
| 41 | 41 | <?php |
| 42 | - $lsx = admin_url( 'themes.php?page=lsx-welcome' ); |
|
| 43 | - $message = sprintf( "Please enter the license and API key's for your add-ons below." ); |
|
| 44 | - $message .= sprintf( " Follow this <a href='%s' title='LSX add-ons'>link</a> to see what extensions are available for LSX.", $lsx ); |
|
| 45 | - ?> |
|
| 42 | + $lsx = admin_url( 'themes.php?page=lsx-welcome' ); |
|
| 43 | + $message = sprintf( "Please enter the license and API key's for your add-ons below." ); |
|
| 44 | + $message .= sprintf( " Follow this <a href='%s' title='LSX add-ons'>link</a> to see what extensions are available for LSX.", $lsx ); |
|
| 45 | + ?> |
|
| 46 | 46 | |
| 47 | 47 | <p class="info"><?php echo wp_kses_post( $message ); ?></p> |
| 48 | 48 | |
| 49 | 49 | <?php |
| 50 | - $api_keys_content = false; |
|
| 51 | - ob_start(); |
|
| 52 | - do_action( 'lsx_framework_api_tab_content', 'api' ); |
|
| 53 | - $api_keys_content = ob_end_clean(); |
|
| 54 | - ?> |
|
| 50 | + $api_keys_content = false; |
|
| 51 | + ob_start(); |
|
| 52 | + do_action( 'lsx_framework_api_tab_content', 'api' ); |
|
| 53 | + $api_keys_content = ob_end_clean(); |
|
| 54 | + ?> |
|
| 55 | 55 | </tbody> |
| 56 | 56 | </table> |
| 57 | 57 | </div> |
@@ -2,30 +2,30 @@ discard block |
||
| 2 | 2 | <?php |
| 3 | 3 | $display_settings_page = false; |
| 4 | 4 | |
| 5 | - if ( class_exists( 'LSX_Currencies' ) ) { |
|
| 5 | + if (class_exists('LSX_Currencies')) { |
|
| 6 | 6 | $display_settings_page = true; |
| 7 | 7 | } |
| 8 | 8 | ?> |
| 9 | 9 | |
| 10 | 10 | <ul class="ui-tab-nav"> |
| 11 | 11 | <?php |
| 12 | - if ( false !== $display_settings_page ) { |
|
| 12 | + if (false !== $display_settings_page) { |
|
| 13 | 13 | ?> |
| 14 | -<li><a href="#ui-settings" class="active"><?php esc_html_e( 'Settings', 'lsx-currencies' ); ?></a></li><?php } ?> |
|
| 14 | +<li><a href="#ui-settings" class="active"><?php esc_html_e('Settings', 'lsx-currencies'); ?></a></li><?php } ?> |
|
| 15 | 15 | <li><a href="#ui-keys" |
| 16 | 16 | <?php |
| 17 | - if ( false === $display_settings_page ) { |
|
| 17 | + if (false === $display_settings_page) { |
|
| 18 | 18 | ?> |
| 19 | -class="active"<?php } ?>><?php esc_html_e( 'License Keys', 'lsx-currencies' ); ?></a></li> |
|
| 19 | +class="active"<?php } ?>><?php esc_html_e('License Keys', 'lsx-currencies'); ?></a></li> |
|
| 20 | 20 | </ul> |
| 21 | 21 | |
| 22 | - <?php if ( false !== $display_settings_page ) { ?> |
|
| 22 | + <?php if (false !== $display_settings_page) { ?> |
|
| 23 | 23 | <div id="ui-settings" class="ui-tab active"> |
| 24 | - <p><?php esc_html_e( 'Please enter your user details (email address, API key, username, etc) below as required for the extensions that you have installed.', 'lsx-currencies' ); ?></p> |
|
| 24 | + <p><?php esc_html_e('Please enter your user details (email address, API key, username, etc) below as required for the extensions that you have installed.', 'lsx-currencies'); ?></p> |
|
| 25 | 25 | |
| 26 | 26 | <table class="form-table" style="margin-top:-13px !important;"> |
| 27 | 27 | <tbody> |
| 28 | - <?php do_action( 'lsx_framework_api_tab_content', 'settings' ); ?> |
|
| 28 | + <?php do_action('lsx_framework_api_tab_content', 'settings'); ?> |
|
| 29 | 29 | </tbody> |
| 30 | 30 | </table> |
| 31 | 31 | </div> |
@@ -33,28 +33,28 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | <div id="ui-keys" class="ui-tab |
| 35 | 35 | <?php |
| 36 | - if ( false === $display_settings_page ) { |
|
| 36 | + if (false === $display_settings_page) { |
|
| 37 | 37 | ?> |
| 38 | 38 | active<?php } ?>"> |
| 39 | 39 | <table class="form-table" style="margin-top:-13px !important;"> |
| 40 | 40 | <tbody> |
| 41 | 41 | <?php |
| 42 | - $lsx = admin_url( 'themes.php?page=lsx-welcome' ); |
|
| 43 | - $message = sprintf( "Please enter the license and API key's for your add-ons below." ); |
|
| 44 | - $message .= sprintf( " Follow this <a href='%s' title='LSX add-ons'>link</a> to see what extensions are available for LSX.", $lsx ); |
|
| 42 | + $lsx = admin_url('themes.php?page=lsx-welcome'); |
|
| 43 | + $message = sprintf("Please enter the license and API key's for your add-ons below."); |
|
| 44 | + $message .= sprintf(" Follow this <a href='%s' title='LSX add-ons'>link</a> to see what extensions are available for LSX.", $lsx); |
|
| 45 | 45 | ?> |
| 46 | 46 | |
| 47 | - <p class="info"><?php echo wp_kses_post( $message ); ?></p> |
|
| 47 | + <p class="info"><?php echo wp_kses_post($message); ?></p> |
|
| 48 | 48 | |
| 49 | 49 | <?php |
| 50 | 50 | $api_keys_content = false; |
| 51 | 51 | ob_start(); |
| 52 | - do_action( 'lsx_framework_api_tab_content', 'api' ); |
|
| 52 | + do_action('lsx_framework_api_tab_content', 'api'); |
|
| 53 | 53 | $api_keys_content = ob_end_clean(); |
| 54 | 54 | ?> |
| 55 | 55 | </tbody> |
| 56 | 56 | </table> |
| 57 | 57 | </div> |
| 58 | 58 | |
| 59 | - <?php do_action( 'lsx_framework_api_tab_bottom', 'api' ); ?> |
|
| 59 | + <?php do_action('lsx_framework_api_tab_bottom', 'api'); ?> |
|
| 60 | 60 | </div> |
@@ -16,104 +16,104 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class FacetWP { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Holds instance of the class |
|
| 21 | - * |
|
| 22 | - * @var object \lsx\currencies\classes\FacetWP() |
|
| 23 | - */ |
|
| 24 | - private static $instance; |
|
| 19 | + /** |
|
| 20 | + * Holds instance of the class |
|
| 21 | + * |
|
| 22 | + * @var object \lsx\currencies\classes\FacetWP() |
|
| 23 | + */ |
|
| 24 | + private static $instance; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Holds the current currency. |
|
| 28 | - * |
|
| 29 | - * @var boolean |
|
| 30 | - */ |
|
| 31 | - public $currency = false; |
|
| 26 | + /** |
|
| 27 | + * Holds the current currency. |
|
| 28 | + * |
|
| 29 | + * @var boolean |
|
| 30 | + */ |
|
| 31 | + public $currency = false; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor |
|
| 35 | - */ |
|
| 36 | - public function __construct() { |
|
| 37 | - add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 20, 2 ); |
|
| 38 | - add_action( 'lsx_currencies_rates_refreshed', array( $this, 'refresh_the_currencies' ), 20 ); |
|
| 39 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor |
|
| 35 | + */ |
|
| 36 | + public function __construct() { |
|
| 37 | + add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 20, 2 ); |
|
| 38 | + add_action( 'lsx_currencies_rates_refreshed', array( $this, 'refresh_the_currencies' ), 20 ); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Return an instance of this class. |
|
| 43 | - * |
|
| 44 | - * @return object |
|
| 45 | - */ |
|
| 46 | - public static function init() { |
|
| 47 | - // If the single instance hasn't been set, set it now. |
|
| 48 | - if ( ! isset( self::$instance ) ) { |
|
| 49 | - self::$instance = new self(); |
|
| 50 | - } |
|
| 51 | - return self::$instance; |
|
| 52 | - } |
|
| 41 | + /** |
|
| 42 | + * Return an instance of this class. |
|
| 43 | + * |
|
| 44 | + * @return object |
|
| 45 | + */ |
|
| 46 | + public static function init() { |
|
| 47 | + // If the single instance hasn't been set, set it now. |
|
| 48 | + if ( ! isset( self::$instance ) ) { |
|
| 49 | + self::$instance = new self(); |
|
| 50 | + } |
|
| 51 | + return self::$instance; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Alter the rows and include extra facets rows for the continents. |
|
| 56 | - */ |
|
| 57 | - public function facetwp_index_row_data( $rows, $params ) { |
|
| 58 | - switch ( $params['facet']['source'] ) { |
|
| 59 | - case 'cf/price': |
|
| 60 | - // only convert a price to the base currency if the setting is active. |
|
| 61 | - // If $rows is empty then there is no base currency set. |
|
| 62 | - if ( true === lsx_currencies()->convert_to_single && empty( $rows ) ) { |
|
| 63 | - lsx_currencies()->frontend->set_defaults(); |
|
| 64 | - $additional_prices = get_post_meta( $params['defaults']['post_id'], 'additional_prices', false ); |
|
| 54 | + /** |
|
| 55 | + * Alter the rows and include extra facets rows for the continents. |
|
| 56 | + */ |
|
| 57 | + public function facetwp_index_row_data( $rows, $params ) { |
|
| 58 | + switch ( $params['facet']['source'] ) { |
|
| 59 | + case 'cf/price': |
|
| 60 | + // only convert a price to the base currency if the setting is active. |
|
| 61 | + // If $rows is empty then there is no base currency set. |
|
| 62 | + if ( true === lsx_currencies()->convert_to_single && empty( $rows ) ) { |
|
| 63 | + lsx_currencies()->frontend->set_defaults(); |
|
| 64 | + $additional_prices = get_post_meta( $params['defaults']['post_id'], 'additional_prices', false ); |
|
| 65 | 65 | |
| 66 | - if ( ! empty( $additional_prices ) && isset( $additional_prices[0] ) && ! empty( lsx_currencies()->frontend->rates ) ) { |
|
| 67 | - $row_currency = $additional_prices[0]['currency']; |
|
| 68 | - $row_value = $additional_prices[0]['amount']; |
|
| 69 | - $current_currency = lsx_currencies()->frontend->current_currency; |
|
| 70 | - $usd_value = $row_value / lsx_currencies()->frontend->rates->$row_currency; |
|
| 71 | - if ( $row_currency !== $current_currency ) { |
|
| 72 | - $usd_value = $usd_value * lsx_currencies()->frontend->rates->$current_currency; |
|
| 73 | - } |
|
| 74 | - $new_row = $params['defaults']; |
|
| 75 | - $new_row['facet_value'] = round( $usd_value, 0 ); |
|
| 76 | - $new_row['facet_display_value'] = round( $usd_value, 0 ); |
|
| 77 | - $rows[] = $new_row; |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - break; |
|
| 66 | + if ( ! empty( $additional_prices ) && isset( $additional_prices[0] ) && ! empty( lsx_currencies()->frontend->rates ) ) { |
|
| 67 | + $row_currency = $additional_prices[0]['currency']; |
|
| 68 | + $row_value = $additional_prices[0]['amount']; |
|
| 69 | + $current_currency = lsx_currencies()->frontend->current_currency; |
|
| 70 | + $usd_value = $row_value / lsx_currencies()->frontend->rates->$row_currency; |
|
| 71 | + if ( $row_currency !== $current_currency ) { |
|
| 72 | + $usd_value = $usd_value * lsx_currencies()->frontend->rates->$current_currency; |
|
| 73 | + } |
|
| 74 | + $new_row = $params['defaults']; |
|
| 75 | + $new_row['facet_value'] = round( $usd_value, 0 ); |
|
| 76 | + $new_row['facet_display_value'] = round( $usd_value, 0 ); |
|
| 77 | + $rows[] = $new_row; |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + break; |
|
| 81 | 81 | |
| 82 | - default: |
|
| 83 | - break; |
|
| 84 | - } |
|
| 85 | - return $rows; |
|
| 86 | - } |
|
| 82 | + default: |
|
| 83 | + break; |
|
| 84 | + } |
|
| 85 | + return $rows; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * This will refresh the saved currencies that ar not the same as the base currency. |
|
| 90 | - * |
|
| 91 | - * @return void |
|
| 92 | - */ |
|
| 93 | - public function refresh_the_currencies() { |
|
| 94 | - if ( true === lsx_currencies()->convert_to_single ) { |
|
| 95 | - add_action( 'wp_footer', array( $this, 'trigger_the_index' ) ); |
|
| 96 | - } |
|
| 97 | - } |
|
| 88 | + /** |
|
| 89 | + * This will refresh the saved currencies that ar not the same as the base currency. |
|
| 90 | + * |
|
| 91 | + * @return void |
|
| 92 | + */ |
|
| 93 | + public function refresh_the_currencies() { |
|
| 94 | + if ( true === lsx_currencies()->convert_to_single ) { |
|
| 95 | + add_action( 'wp_footer', array( $this, 'trigger_the_index' ) ); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Grabs the tour ids and runs them through the index. |
|
| 101 | - * |
|
| 102 | - * @return void |
|
| 103 | - */ |
|
| 104 | - public function trigger_the_index() { |
|
| 105 | - $tours_args = array( |
|
| 106 | - 'post_type' => 'tour', |
|
| 107 | - 'post_status' => 'publish', |
|
| 108 | - 'posts_per_page' => '-1', |
|
| 109 | - 'nopagin' => true, |
|
| 110 | - 'fields' => 'ids', |
|
| 111 | - ); |
|
| 112 | - $tours_query = new \WP_Query( $tours_args ); |
|
| 113 | - if ( $tours_query->have_posts() ) { |
|
| 114 | - foreach ( $tours_query->posts as $tour_id ) { |
|
| 115 | - FWP()->indexer->index( $tour_id ); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 99 | + /** |
|
| 100 | + * Grabs the tour ids and runs them through the index. |
|
| 101 | + * |
|
| 102 | + * @return void |
|
| 103 | + */ |
|
| 104 | + public function trigger_the_index() { |
|
| 105 | + $tours_args = array( |
|
| 106 | + 'post_type' => 'tour', |
|
| 107 | + 'post_status' => 'publish', |
|
| 108 | + 'posts_per_page' => '-1', |
|
| 109 | + 'nopagin' => true, |
|
| 110 | + 'fields' => 'ids', |
|
| 111 | + ); |
|
| 112 | + $tours_query = new \WP_Query( $tours_args ); |
|
| 113 | + if ( $tours_query->have_posts() ) { |
|
| 114 | + foreach ( $tours_query->posts as $tour_id ) { |
|
| 115 | + FWP()->indexer->index( $tour_id ); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * Constructor |
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | - add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 20, 2 ); |
|
| 38 | - add_action( 'lsx_currencies_rates_refreshed', array( $this, 'refresh_the_currencies' ), 20 ); |
|
| 37 | + add_filter('facetwp_indexer_row_data', array($this, 'facetwp_index_row_data'), 20, 2); |
|
| 38 | + add_action('lsx_currencies_rates_refreshed', array($this, 'refresh_the_currencies'), 20); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public static function init() { |
| 47 | 47 | // If the single instance hasn't been set, set it now. |
| 48 | - if ( ! isset( self::$instance ) ) { |
|
| 48 | + if (!isset(self::$instance)) { |
|
| 49 | 49 | self::$instance = new self(); |
| 50 | 50 | } |
| 51 | 51 | return self::$instance; |
@@ -54,26 +54,26 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * Alter the rows and include extra facets rows for the continents. |
| 56 | 56 | */ |
| 57 | - public function facetwp_index_row_data( $rows, $params ) { |
|
| 58 | - switch ( $params['facet']['source'] ) { |
|
| 57 | + public function facetwp_index_row_data($rows, $params) { |
|
| 58 | + switch ($params['facet']['source']) { |
|
| 59 | 59 | case 'cf/price': |
| 60 | 60 | // only convert a price to the base currency if the setting is active. |
| 61 | 61 | // If $rows is empty then there is no base currency set. |
| 62 | - if ( true === lsx_currencies()->convert_to_single && empty( $rows ) ) { |
|
| 62 | + if (true === lsx_currencies()->convert_to_single && empty($rows)) { |
|
| 63 | 63 | lsx_currencies()->frontend->set_defaults(); |
| 64 | - $additional_prices = get_post_meta( $params['defaults']['post_id'], 'additional_prices', false ); |
|
| 64 | + $additional_prices = get_post_meta($params['defaults']['post_id'], 'additional_prices', false); |
|
| 65 | 65 | |
| 66 | - if ( ! empty( $additional_prices ) && isset( $additional_prices[0] ) && ! empty( lsx_currencies()->frontend->rates ) ) { |
|
| 66 | + if (!empty($additional_prices) && isset($additional_prices[0]) && !empty(lsx_currencies()->frontend->rates)) { |
|
| 67 | 67 | $row_currency = $additional_prices[0]['currency']; |
| 68 | 68 | $row_value = $additional_prices[0]['amount']; |
| 69 | 69 | $current_currency = lsx_currencies()->frontend->current_currency; |
| 70 | 70 | $usd_value = $row_value / lsx_currencies()->frontend->rates->$row_currency; |
| 71 | - if ( $row_currency !== $current_currency ) { |
|
| 71 | + if ($row_currency !== $current_currency) { |
|
| 72 | 72 | $usd_value = $usd_value * lsx_currencies()->frontend->rates->$current_currency; |
| 73 | 73 | } |
| 74 | 74 | $new_row = $params['defaults']; |
| 75 | - $new_row['facet_value'] = round( $usd_value, 0 ); |
|
| 76 | - $new_row['facet_display_value'] = round( $usd_value, 0 ); |
|
| 75 | + $new_row['facet_value'] = round($usd_value, 0); |
|
| 76 | + $new_row['facet_display_value'] = round($usd_value, 0); |
|
| 77 | 77 | $rows[] = $new_row; |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | * @return void |
| 92 | 92 | */ |
| 93 | 93 | public function refresh_the_currencies() { |
| 94 | - if ( true === lsx_currencies()->convert_to_single ) { |
|
| 95 | - add_action( 'wp_footer', array( $this, 'trigger_the_index' ) ); |
|
| 94 | + if (true === lsx_currencies()->convert_to_single) { |
|
| 95 | + add_action('wp_footer', array($this, 'trigger_the_index')); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -102,17 +102,17 @@ discard block |
||
| 102 | 102 | * @return void |
| 103 | 103 | */ |
| 104 | 104 | public function trigger_the_index() { |
| 105 | - $tours_args = array( |
|
| 105 | + $tours_args = array( |
|
| 106 | 106 | 'post_type' => 'tour', |
| 107 | 107 | 'post_status' => 'publish', |
| 108 | 108 | 'posts_per_page' => '-1', |
| 109 | 109 | 'nopagin' => true, |
| 110 | 110 | 'fields' => 'ids', |
| 111 | 111 | ); |
| 112 | - $tours_query = new \WP_Query( $tours_args ); |
|
| 113 | - if ( $tours_query->have_posts() ) { |
|
| 114 | - foreach ( $tours_query->posts as $tour_id ) { |
|
| 115 | - FWP()->indexer->index( $tour_id ); |
|
| 112 | + $tours_query = new \WP_Query($tours_args); |
|
| 113 | + if ($tours_query->have_posts()) { |
|
| 114 | + foreach ($tours_query->posts as $tour_id) { |
|
| 115 | + FWP()->indexer->index($tour_id); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |