@@ -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 = 'https://openexchangerates.org/api/latest.json?app_id=' . $this->app_id; |
|
| 196 | + $this->api_url = 'https://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 | } |