lightspeeddevelopment /
lsx-currencies
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * LSX Currency Main Class |
||
| 4 | * |
||
| 5 | * @package LSX Currencies |
||
| 6 | * @author LightSpeed |
||
| 7 | * @license GPL3 |
||
| 8 | * @link |
||
| 9 | * @copyright 2019 LightSpeed |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace lsx\currencies\classes; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * The main class |
||
| 16 | */ |
||
| 17 | class Currencies { |
||
| 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 */ |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 65 | public $plugin_slug = 'lsx-currencies'; |
||
|
0 ignored issues
–
show
|
|||
| 66 | |||
| 67 | /** @var array */ |
||
|
0 ignored issues
–
show
|
|||
| 68 | public $options = false; |
||
| 69 | |||
| 70 | /** @var string */ |
||
|
0 ignored issues
–
show
|
|||
| 71 | public $base_currency = 'USD'; |
||
| 72 | |||
| 73 | /** @var array */ |
||
|
0 ignored issues
–
show
|
|||
| 74 | public $additional_currencies = array(); |
||
| 75 | |||
| 76 | /** @var array */ |
||
|
0 ignored issues
–
show
|
|||
| 77 | public $available_currencies = array(); |
||
| 78 | |||
| 79 | /** @var array */ |
||
|
0 ignored issues
–
show
|
|||
| 80 | public $flag_relations = array(); |
||
| 81 | |||
| 82 | /** @var array */ |
||
|
0 ignored issues
–
show
|
|||
| 83 | public $currency_symbols = array(); |
||
| 84 | |||
| 85 | /** @var boolean */ |
||
|
0 ignored issues
–
show
|
|||
| 86 | public $multi_prices = false; |
||
| 87 | |||
| 88 | /** @var boolean */ |
||
|
0 ignored issues
–
show
|
|||
| 89 | public $convert_to_single = false; |
||
| 90 | |||
| 91 | /** @var boolean */ |
||
|
0 ignored issues
–
show
|
|||
| 92 | public $app_id = false; |
||
| 93 | |||
| 94 | /* Currency Switcher Options */ |
||
| 95 | /** @var array */ |
||
|
0 ignored issues
–
show
|
|||
| 96 | public $menus = false; |
||
|
0 ignored issues
–
show
|
|||
| 97 | |||
| 98 | /** @var boolean */ |
||
|
0 ignored issues
–
show
|
|||
| 99 | public $display_flags = false; |
||
| 100 | |||
| 101 | /** @var string */ |
||
|
0 ignored issues
–
show
|
|||
| 102 | public $flag_position = 'left'; |
||
| 103 | |||
| 104 | /** @var string */ |
||
|
0 ignored issues
–
show
|
|||
| 105 | public $switcher_symbol_position = 'right'; |
||
| 106 | |||
| 107 | /** @var boolean */ |
||
|
0 ignored issues
–
show
|
|||
| 108 | public $remove_decimals = false; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Constructor |
||
| 112 | */ |
||
| 113 | public function __construct() { |
||
|
0 ignored issues
–
show
|
|||
| 114 | add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); |
||
| 115 | add_action( 'plugins_loaded', array( $this, 'set_defaults' ) ); |
||
| 116 | } |
||
|
0 ignored issues
–
show
|
|||
| 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 ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 126 | self::$instance = new self(); |
||
| 127 | } |
||
|
0 ignored issues
–
show
|
|||
| 128 | return self::$instance; |
||
| 129 | } |
||
|
0 ignored issues
–
show
|
|||
| 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' ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 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' ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 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 | } |
||
|
0 ignored issues
–
show
|
|||
| 153 | |||
| 154 | /** |
||
| 155 | * Get the options |
||
| 156 | */ |
||
| 157 | public function set_defaults() { |
||
| 158 | $settings_tab = 'display'; |
||
| 159 | if ( function_exists( 'tour_operator' ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 160 | $options = get_option( '_lsx-to_settings', false ); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 161 | $settings_tab = 'general'; |
||
| 162 | } else { |
||
| 163 | $options = get_option( '_lsx_settings', false ); |
||
| 164 | |||
| 165 | if ( false === $options ) { |
||
|
0 ignored issues
–
show
|
|||
| 166 | $options = get_option( '_lsx_lsx-settings', false ); |
||
| 167 | } |
||
| 168 | } |
||
| 169 | |||
| 170 | if ( false !== $options ) { |
||
|
0 ignored issues
–
show
|
|||
| 171 | $this->options = $options; |
||
| 172 | $this->migration_uix_to_customize(); |
||
| 173 | |||
| 174 | if ( isset( $this->options[ $settings_tab ] ) && isset( $this->options[ $settings_tab ]['currency'] ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 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'] ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 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'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 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'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 187 | $this->convert_to_single = true; |
||
| 188 | } |
||
| 189 | |||
| 190 | if ( isset( $this->options[ $settings_tab ]['remove_decimals'] ) && 'on' === $this->options[ $settings_tab ]['remove_decimals'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 191 | $this->remove_decimals = true; |
||
| 192 | } |
||
| 193 | |||
| 194 | if ( isset( $this->options['api']['openexchange_api'] ) && '' !== $this->options['api']['openexchange_api'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 195 | $this->app_id = $this->options['api']['openexchange_api']; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 196 | $this->api_url = 'https://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 ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 203 | $this->display_flags = true; |
||
| 204 | } |
||
| 205 | |||
| 206 | if ( get_theme_mod( 'lsx_currencies_flag_position', false ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 207 | $this->flag_position = 'right'; |
||
| 208 | } |
||
| 209 | |||
| 210 | if ( get_theme_mod( 'lsx_currencies_currency_switcher_position', false ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 211 | $this->switcher_symbol_position = 'left'; |
||
| 212 | } |
||
| 213 | } |
||
|
0 ignored issues
–
show
|
|||
| 214 | $this->available_currencies = $this->get_available_currencies(); |
||
| 215 | $this->flag_relations = $this->get_flag_relations(); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 216 | $this->currency_symbols = $this->get_currency_symbols(); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 217 | } |
||
|
0 ignored issues
–
show
|
|||
| 218 | |||
| 219 | /** |
||
|
0 ignored issues
–
show
|
|||
| 220 | * Returns Currency Flag for currency code provided |
||
| 221 | * |
||
| 222 | * @param $key string |
||
|
0 ignored issues
–
show
|
|||
| 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 | } |
||
|
0 ignored issues
–
show
|
|||
| 229 | |||
| 230 | /** |
||
| 231 | * Get Currency symbol. |
||
| 232 | * |
||
| 233 | * @param string $currency |
||
|
0 ignored issues
–
show
|
|||
| 234 | * @return string |
||
| 235 | */ |
||
| 236 | public function get_currency_symbol( $currency = '' ) { |
||
| 237 | if ( ! $currency ) { |
||
|
0 ignored issues
–
show
|
|||
| 238 | $currency = $this->base_currency; |
||
| 239 | } |
||
|
0 ignored issues
–
show
|
|||
| 240 | $currency_symbol = isset( $this->currency_symbols[ $currency ] ) ? $this->currency_symbols[ $currency ] : ''; |
||
| 241 | return $currency_symbol; |
||
| 242 | } |
||
|
0 ignored issues
–
show
|
|||
| 243 | |||
| 244 | /** |
||
| 245 | * Returns an array of the available currencies |
||
| 246 | * |
||
| 247 | * @return array |
||
| 248 | */ |
||
| 249 | public function get_available_currencies() { |
||
|
0 ignored issues
–
show
|
|||
| 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 ) { |
||
|
0 ignored issues
–
show
|
|||
| 287 | $free_currencies = array_merge( $free_currencies, $paid_currencies ); |
||
| 288 | asort( $free_currencies ); |
||
| 289 | } |
||
| 290 | |||
| 291 | return $free_currencies; |
||
| 292 | } |
||
|
0 ignored issues
–
show
|
|||
| 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 | } |
||
|
0 ignored issues
–
show
|
|||
| 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( |
||
|
0 ignored issues
–
show
|
|||
| 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 | ) ); |
||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 504 | } |
||
|
0 ignored issues
–
show
|
|||
| 505 | |||
| 506 | /** |
||
|
0 ignored issues
–
show
|
|||
| 507 | * Sanitize checkbox. |
||
| 508 | * |
||
| 509 | * @param $input html |
||
|
0 ignored issues
–
show
|
|||
| 510 | * @return mixed |
||
| 511 | */ |
||
| 512 | public function sanitize_checkbox( $input ) { |
||
| 513 | return ( 1 === absint( $input ) ) ? 1 : 0; |
||
| 514 | } |
||
|
0 ignored issues
–
show
|
|||
| 515 | |||
| 516 | /** |
||
|
0 ignored issues
–
show
|
|||
| 517 | * Sanitize select. |
||
| 518 | * |
||
| 519 | * @param $input html |
||
|
0 ignored issues
–
show
|
|||
| 520 | * @return mixed |
||
| 521 | */ |
||
| 522 | public function sanitize_select( $input ) { |
||
| 523 | if ( is_string( $input ) || is_integer( $input ) || is_bool( $input ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 524 | return $input; |
||
| 525 | } else { |
||
| 526 | return ''; |
||
| 527 | } |
||
| 528 | } |
||
|
0 ignored issues
–
show
|
|||
| 529 | |||
| 530 | /** |
||
|
0 ignored issues
–
show
|
|||
| 531 | * Sanitize textarea. |
||
| 532 | * |
||
| 533 | * @param $input html |
||
|
0 ignored issues
–
show
|
|||
| 534 | * @return mixed |
||
| 535 | */ |
||
| 536 | public function sanitize_textarea( $input ) { |
||
| 537 | return wp_kses_post( $input ); |
||
| 538 | } |
||
|
0 ignored issues
–
show
|
|||
| 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 ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 549 | if ( isset( $this->options['display'] ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 550 | if ( isset( $this->options['display']['currency_menu_switcher'] ) && is_array( $this->options['display']['currency_menu_switcher'] ) && ! empty( $this->options['display']['currency_menu_switcher'] ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 551 | $currency_menu_position = $this->options['display']['currency_menu_switcher']; |
||
| 552 | |||
| 553 | foreach ( $currency_menu_position as $key => $value ) { |
||
|
0 ignored issues
–
show
|
|||
| 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'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 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'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 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'] ) { |
||
|
0 ignored issues
–
show
|
|||
| 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 | } |
||
|
0 ignored issues
–
show
|
|||
| 575 | } |
||
| 576 |