Passed
Push — dependabot/composer/wpackagist... ( 239345 )
by
unknown
05:47
created
includes/settings/general.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
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>
Please login to merge, or discard this patch.
includes/template-tags.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
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
 block discarded – undo
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');
Please login to merge, or discard this patch.
lsx-currencies.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
classes/deprecated/class-lsx-currencies.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
classes/class-woocommerce.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
includes/settings/api.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,30 +2,30 @@  discard block
 block discarded – undo
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
 block discarded – undo
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>
Please login to merge, or discard this patch.
classes/class-facetwp.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
classes/class-admin.php 1 patch
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 * Constructor
28 28
 	 */
29 29
 	public function __construct() {
30
-		add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
31
-		add_action( 'init', array( $this, 'create_settings_page' ), 100 );
32
-		add_filter( 'lsx_framework_settings_tabs', array( $this, 'register_tabs' ), 100, 1 );
33
-		add_filter( 'lsx_to_tour_custom_fields', array( $this, 'fields' ), 80, 1 );
34
-		add_action( 'customize_register', array( $this, 'customize_register' ), 20 );
30
+		add_action('admin_enqueue_scripts', array($this, 'assets'));
31
+		add_action('init', array($this, 'create_settings_page'), 100);
32
+		add_filter('lsx_framework_settings_tabs', array($this, 'register_tabs'), 100, 1);
33
+		add_filter('lsx_to_tour_custom_fields', array($this, 'fields'), 80, 1);
34
+		add_action('customize_register', array($this, 'customize_register'), 20);
35 35
 	}
36 36
 
37 37
 	/**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function init() {
43 43
 		// If the single instance hasn't been set, set it now.
44
-		if ( ! isset( self::$instance ) ) {
44
+		if (!isset(self::$instance)) {
45 45
 			self::$instance = new self();
46 46
 		}
47 47
 		return self::$instance;
@@ -52,25 +52,25 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function assets() {
54 54
 		//wp_enqueue_script( 'lsx-currencies-admin', LSX_CURRENCIES_URL . 'assets/js/lsx-currencies-admin.min.js', array( 'jquery' ), LSX_CURRENCIES_VER, true );
55
-		wp_enqueue_style( 'lsx-currencies-admin', LSX_CURRENCIES_URL . 'assets/css/lsx-currencies-admin.css', array(), LSX_CURRENCIES_VER );
55
+		wp_enqueue_style('lsx-currencies-admin', LSX_CURRENCIES_URL.'assets/css/lsx-currencies-admin.css', array(), LSX_CURRENCIES_VER);
56 56
 	}
57 57
 
58 58
 	/**
59 59
 	 * Returns the array of settings to the UIX Class
60 60
 	 */
61 61
 	public function create_settings_page() {
62
-		if ( is_admin() ) {
63
-			if ( ! class_exists( '\lsx\ui\uix' ) && ! function_exists( 'tour_operator' ) ) {
64
-				include_once LSX_CURRENCIES_PATH . 'vendor/uix/uix.php';
62
+		if (is_admin()) {
63
+			if (!class_exists('\lsx\ui\uix') && !function_exists('tour_operator')) {
64
+				include_once LSX_CURRENCIES_PATH.'vendor/uix/uix.php';
65 65
 				$pages = $this->settings_page_array();
66
-				$uix = \lsx\ui\uix::get_instance( 'lsx' );
67
-				$uix->register_pages( $pages );
66
+				$uix = \lsx\ui\uix::get_instance('lsx');
67
+				$uix->register_pages($pages);
68 68
 			}
69
-			add_action( 'lsx_to_framework_dashboard_tab_content', array( $this, 'general_settings' ), 11, 1 );
70
-			add_action( 'lsx_to_framework_api_tab_content', array( $this, 'api_settings' ), 11, 1 );
69
+			add_action('lsx_to_framework_dashboard_tab_content', array($this, 'general_settings'), 11, 1);
70
+			add_action('lsx_to_framework_api_tab_content', array($this, 'api_settings'), 11, 1);
71 71
 
72
-			add_action( 'lsx_framework_display_tab_content', array( $this, 'general_settings' ), 11, 1 );
73
-			add_action( 'lsx_framework_api_tab_content', array( $this, 'api_settings' ), 11, 1 );
72
+			add_action('lsx_framework_display_tab_content', array($this, 'general_settings'), 11, 1);
73
+			add_action('lsx_framework_api_tab_content', array($this, 'api_settings'), 11, 1);
74 74
 		}
75 75
 	}
76 76
 
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 	 * Returns the array of settings to the UIX Class
79 79
 	 */
80 80
 	public function settings_page_array() {
81
-		$tabs = apply_filters( 'lsx_framework_settings_tabs', array() );
81
+		$tabs = apply_filters('lsx_framework_settings_tabs', array());
82 82
 
83 83
 		return array(
84 84
 			'settings'  => array(
85
-				'page_title'  => esc_html__( 'Theme Options', 'lsx-currencies' ),
86
-				'menu_title'  => esc_html__( 'Theme Options', 'lsx-currencies' ),
85
+				'page_title'  => esc_html__('Theme Options', 'lsx-currencies'),
86
+				'menu_title'  => esc_html__('Theme Options', 'lsx-currencies'),
87 87
 				'capability'  => 'manage_options',
88 88
 				'icon'        => 'dashicons-book-alt',
89 89
 				'parent'      => 'themes.php',
90
-				'save_button' => esc_html__( 'Save Changes', 'lsx-currencies' ),
90
+				'save_button' => esc_html__('Save Changes', 'lsx-currencies'),
91 91
 				'tabs'        => $tabs,
92 92
 			),
93 93
 		);
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 	/**
97 97
 	 * Register tabs
98 98
 	 */
99
-	public function register_tabs( $tabs ) {
99
+	public function register_tabs($tabs) {
100 100
 		$default = true;
101 101
 
102
-		if ( false !== $tabs && is_array( $tabs ) && count( $tabs ) > 0 ) {
102
+		if (false !== $tabs && is_array($tabs) && count($tabs) > 0) {
103 103
 			$default = false;
104 104
 		}
105 105
 
106
-		if ( ! function_exists( 'tour_operator' ) ) {
106
+		if (!function_exists('tour_operator')) {
107 107
 			/*if ( ! array_key_exists( 'general', $tabs ) ) {
108 108
 				$tabs['general'] = array(
109 109
 					'page_title'        => '',
@@ -116,24 +116,24 @@  discard block
 block discarded – undo
116 116
 				$default = false;
117 117
 			}*/
118 118
 
119
-			if ( ! array_key_exists( 'display', $tabs ) ) {
119
+			if (!array_key_exists('display', $tabs)) {
120 120
 				$tabs['display'] = array(
121 121
 					'page_title'        => '',
122 122
 					'page_description'  => '',
123
-					'menu_title'        => esc_html__( 'Display', 'lsx-currencies' ),
124
-					'template'          => LSX_CURRENCIES_PATH . 'includes/settings/display.php',
123
+					'menu_title'        => esc_html__('Display', 'lsx-currencies'),
124
+					'template'          => LSX_CURRENCIES_PATH.'includes/settings/display.php',
125 125
 					'default'           => $default,
126 126
 				);
127 127
 
128 128
 				$default = false;
129 129
 			}
130 130
 
131
-			if ( ! array_key_exists( 'api', $tabs ) ) {
131
+			if (!array_key_exists('api', $tabs)) {
132 132
 				$tabs['api'] = array(
133 133
 					'page_title'        => '',
134 134
 					'page_description'  => '',
135
-					'menu_title'        => esc_html__( 'API', 'lsx-currencies' ),
136
-					'template'          => LSX_CURRENCIES_PATH . 'includes/settings/api.php',
135
+					'menu_title'        => esc_html__('API', 'lsx-currencies'),
136
+					'template'          => LSX_CURRENCIES_PATH.'includes/settings/api.php',
137 137
 					'default'           => $default,
138 138
 				);
139 139
 
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
 	 * @param $tab string
151 151
 	 * @return null
152 152
 	 */
153
-	public function general_settings( $tab = 'general' ) {
154
-		if ( 'currency_switcher' === $tab ) {
153
+	public function general_settings($tab = 'general') {
154
+		if ('currency_switcher' === $tab) {
155 155
 			$this->base_currency_field();
156 156
 			$this->additional_currencies_field();
157 157
 			$this->remove_decimals_field();
158
-			if ( function_exists( 'tour_operator' ) ) {
158
+			if (function_exists('tour_operator')) {
159 159
 				$this->enable_multiple_prices_field();
160 160
 				$this->enable_convert_to_single_currency_field();
161 161
 			}
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @param $tab string
169 169
 	 * @return null
170 170
 	 */
171
-	public function api_settings( $tab = 'general' ) {
172
-		if ( 'settings' === $tab ) {
171
+	public function api_settings($tab = 'general') {
172
+		if ('settings' === $tab) {
173 173
 			$this->currency_api_heading();
174 174
 			$this->api_key_field();
175 175
 		}
@@ -184,20 +184,20 @@  discard block
 block discarded – undo
184 184
 			<th scope="row">
185 185
 				<label for="currency">
186 186
 				<?php
187
-				esc_html_e( 'Base Currency', 'lsx-currencies' );
187
+				esc_html_e('Base Currency', 'lsx-currencies');
188 188
 				?>
189 189
 				</label>
190 190
 			</th>
191 191
 			<td>
192 192
 				<?php
193
-				if ( ! function_exists( 'WC' ) ) {
193
+				if (!function_exists('WC')) {
194 194
 					?>
195 195
 					<select value="{{currency}}" name="currency">
196 196
 						<?php
197
-						foreach ( lsx_currencies()->available_currencies as $currency_id => $currency_label ) {
197
+						foreach (lsx_currencies()->available_currencies as $currency_id => $currency_label) {
198 198
 							$selected = '';
199 199
 
200
-							if ( lsx_currencies()->base_currency === $currency_id ) {
200
+							if (lsx_currencies()->base_currency === $currency_id) {
201 201
 								$selected = 'selected="selected"';
202 202
 							}
203 203
 							$allowed_html = array(
@@ -206,19 +206,19 @@  discard block
 block discarded – undo
206 206
 									'selected' => array(),
207 207
 								),
208 208
 							);
209
-							echo wp_kses( '<option value="' . $currency_id . '" ' . $selected . '>' . $currency_label . '</option>', $allowed_html );
209
+							echo wp_kses('<option value="'.$currency_id.'" '.$selected.'>'.$currency_label.'</option>', $allowed_html);
210 210
 						}
211 211
 						?>
212 212
 					</select>
213 213
 					<?php
214 214
 				} else {
215 215
 					$currency_label = '';
216
-					if ( isset( lsx_currencies()->available_currencies[ lsx_currencies()->base_currency ] ) ) {
217
-						$currency_label = lsx_currencies()->available_currencies[ lsx_currencies()->base_currency ];
216
+					if (isset(lsx_currencies()->available_currencies[lsx_currencies()->base_currency])) {
217
+						$currency_label = lsx_currencies()->available_currencies[lsx_currencies()->base_currency];
218 218
 					}
219 219
 					?>
220
-					<p><?php echo wp_kses_post( lsx_currencies()->get_currency_flag( lsx_currencies()->base_currency ) ); ?> <?php echo esc_attr( $currency_label ); ?></p>
221
-					<p><small><?php esc_html_e( 'When WooCommerce is active, that currency is used as the base currency.', 'lsx-currencies' ); ?></small></p>
220
+					<p><?php echo wp_kses_post(lsx_currencies()->get_currency_flag(lsx_currencies()->base_currency)); ?> <?php echo esc_attr($currency_label); ?></p>
221
+					<p><small><?php esc_html_e('When WooCommerce is active, that currency is used as the base currency.', 'lsx-currencies'); ?></small></p>
222 222
 					<?php
223 223
 				}
224 224
 				?>
@@ -236,26 +236,26 @@  discard block
 block discarded – undo
236 236
 			<th scope="row">
237 237
 				<label for="modules">
238 238
 				<?php
239
-				esc_html_e( 'Additional Currencies', 'lsx-currencies' );
239
+				esc_html_e('Additional Currencies', 'lsx-currencies');
240 240
 				?>
241 241
 				</label>
242 242
 			</th>
243 243
 			<td>
244 244
 				<ul>
245 245
 					<?php
246
-					foreach ( lsx_currencies()->available_currencies as $slug => $label ) {
246
+					foreach (lsx_currencies()->available_currencies as $slug => $label) {
247 247
 						$checked = '';
248 248
 						$hidden  = $checked;
249
-						if ( array_key_exists( $slug, lsx_currencies()->additional_currencies ) || lsx_currencies()->base_currency === $slug ) {
249
+						if (array_key_exists($slug, lsx_currencies()->additional_currencies) || lsx_currencies()->base_currency === $slug) {
250 250
 								$checked = 'checked="checked"';
251 251
 						}
252 252
 
253
-						if ( lsx_currencies()->base_currency === $slug ) {
253
+						if (lsx_currencies()->base_currency === $slug) {
254 254
 								$hidden = 'style="display:none;" class="hidden"';
255 255
 						}
256 256
 						?>
257
-							<li <?php echo wp_kses_post( $hidden ); ?>>
258
-								<input type="checkbox" <?php echo esc_attr( $checked ); ?> data-name="additional_currencies" data-value="<?php echo esc_attr( $slug ); ?>" name="additional_currencies[<?php echo esc_attr( $slug ); ?>]" /> <label for="additional_currencies"><?php echo wp_kses_post( lsx_currencies()->get_currency_flag( $slug ) . $label ); ?></label>
257
+							<li <?php echo wp_kses_post($hidden); ?>>
258
+								<input type="checkbox" <?php echo esc_attr($checked); ?> data-name="additional_currencies" data-value="<?php echo esc_attr($slug); ?>" name="additional_currencies[<?php echo esc_attr($slug); ?>]" /> <label for="additional_currencies"><?php echo wp_kses_post(lsx_currencies()->get_currency_flag($slug).$label); ?></label>
259 259
 							</li>
260 260
 							<?php
261 261
 					}
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 		?>
274 274
 		<tr class="form-field">
275 275
 			<th scope="row">
276
-				<label for="remove_decimals"><?php esc_html_e( 'Remove Decimals', 'lsx-currencies' ); ?></label>
276
+				<label for="remove_decimals"><?php esc_html_e('Remove Decimals', 'lsx-currencies'); ?></label>
277 277
 			</th>
278 278
 			<td>
279 279
 				<input type="checkbox" {{#if remove_decimals}} checked="checked" {{/if}} name="remove_decimals" />
280
-				<small><?php esc_html_e( 'Round down the amount to the nearest full value.', 'lsx-currencies' ); ?></small>
280
+				<small><?php esc_html_e('Round down the amount to the nearest full value.', 'lsx-currencies'); ?></small>
281 281
 			</td>
282 282
 		</tr>
283 283
 		<?php
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 		?>
291 291
 		<tr class="form-field">
292 292
 			<th scope="row">
293
-				<label for="multi_price"><?php esc_html_e( 'Enable Multiple Prices', 'lsx-currencies' ); ?></label>
293
+				<label for="multi_price"><?php esc_html_e('Enable Multiple Prices', 'lsx-currencies'); ?></label>
294 294
 			</th>
295 295
 			<td>
296 296
 				<input type="checkbox" {{#if multi_price}} checked="checked" {{/if}} name="multi_price" />
297
-				<small><?php esc_html_e( 'Allowing you to add specific prices per active currency.', 'lsx-currencies' ); ?></small>
297
+				<small><?php esc_html_e('Allowing you to add specific prices per active currency.', 'lsx-currencies'); ?></small>
298 298
 			</td>
299 299
 		</tr>
300 300
 		<?php
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 		?>
308 308
 		<tr class="form-field">
309 309
 			<th scope="row">
310
-				<label for="convert_to_single_currency"><?php esc_html_e( 'Enable Convert to Single Currency', 'lsx-currencies' ); ?></label>
310
+				<label for="convert_to_single_currency"><?php esc_html_e('Enable Convert to Single Currency', 'lsx-currencies'); ?></label>
311 311
 			</th>
312 312
 			<td>
313 313
 				<input type="checkbox" {{#if convert_to_single_currency}} checked="checked" {{/if}} name="convert_to_single_currency" />
314
-				<small><?php esc_html_e( 'This will convert all prices added to the base currency, the currency switcher will not work.', 'lsx-currencies' ); ?></small>
314
+				<small><?php esc_html_e('This will convert all prices added to the base currency, the currency switcher will not work.', 'lsx-currencies'); ?></small>
315 315
 			</td>
316 316
 		</tr>
317 317
 		<?php
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		?>
325 325
 		<tr class="form-field banner-wrap">
326 326
 			<th class="table_heading" style="padding-bottom:0px;" scope="row" colspan="2">
327
-				<h4 style="margin-bottom:0px;"><?php esc_html_e( 'Openexchange API', 'lsx-currencies' ); ?></h4>
327
+				<h4 style="margin-bottom:0px;"><?php esc_html_e('Openexchange API', 'lsx-currencies'); ?></h4>
328 328
 			</th>
329 329
 		</tr>
330 330
 		<?php
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 		?>
338 338
 		<tr class="form-field">
339 339
 			<th scope="row">
340
-				<i class="dashicons-before dashicons-admin-network"></i><label for="openexchange_api"> <?php esc_html_e( 'Key', 'to-maps' ); ?></label>
340
+				<i class="dashicons-before dashicons-admin-network"></i><label for="openexchange_api"> <?php esc_html_e('Key', 'to-maps'); ?></label>
341 341
 			</th>
342 342
 			<td>
343 343
 				<input type="text" {{#if openexchange_api}} value="{{openexchange_api}}" {{/if}} name="openexchange_api" />
344
-				<br /><small><?php esc_html_e( 'Get your API key here', 'lsx-currencies' ); ?> - <a target="_blank" rel="noopener noreferrer" href="https://openexchangerates.org/signup/free">openexchangerates.org</a></small>
344
+				<br /><small><?php esc_html_e('Get your API key here', 'lsx-currencies'); ?> - <a target="_blank" rel="noopener noreferrer" href="https://openexchangerates.org/signup/free">openexchangerates.org</a></small>
345 345
 			</td>
346 346
 		</tr>
347 347
 		<?php
@@ -350,26 +350,26 @@  discard block
 block discarded – undo
350 350
 	/**
351 351
 	 *  adds in our multiple prices field
352 352
 	 */
353
-	public function fields( $meta_boxes ) {
354
-		if ( true === lsx_currencies()->multi_prices && ! empty( lsx_currencies()->additional_currencies ) ) {
353
+	public function fields($meta_boxes) {
354
+		if (true === lsx_currencies()->multi_prices && !empty(lsx_currencies()->additional_currencies)) {
355 355
 			$currency_options = array();
356 356
 
357
-			foreach ( lsx_currencies()->additional_currencies as $key => $values ) {
358
-				if ( lsx_currencies()->base_currency === $key ) {
357
+			foreach (lsx_currencies()->additional_currencies as $key => $values) {
358
+				if (lsx_currencies()->base_currency === $key) {
359 359
 					continue;
360 360
 				}
361 361
 
362
-				$currency_options[ $key ] = lsx_currencies()->available_currencies[ $key ];
362
+				$currency_options[$key] = lsx_currencies()->available_currencies[$key];
363 363
 			}
364 364
 
365 365
 			$new_boxes = array();
366 366
 			$injected = false;
367
-			if ( ! empty( $meta_boxes ) ) {
368
-				foreach ( $meta_boxes as $meta_box ) {
369
-					if ( 'price' === $meta_box['id'] ) {
367
+			if (!empty($meta_boxes)) {
368
+				foreach ($meta_boxes as $meta_box) {
369
+					if ('price' === $meta_box['id']) {
370 370
 						$new_boxes[] = array(
371 371
 							'id' => 'price',
372
-							'name' => 'Base Price (' . lsx_currencies()->base_currency . ')',
372
+							'name' => 'Base Price ('.lsx_currencies()->base_currency.')',
373 373
 							'type' => 'text',
374 374
 						);
375 375
 						$new_boxes[] = array(
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 					$new_boxes[] = $meta_box;
400 400
 				}
401 401
 			}
402
-			if ( true === $injected ) {
402
+			if (true === $injected) {
403 403
 				$meta_boxes = $new_boxes;
404 404
 			}
405 405
 		}
@@ -411,106 +411,106 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @since 1.1.1
413 413
 	 */
414
-	public function customize_register( $wp_customize ) {
414
+	public function customize_register($wp_customize) {
415 415
 		/**
416 416
 		 * Panel.
417 417
 		 */
418
-		$wp_customize->add_panel( 'lsx_currencies', array(
418
+		$wp_customize->add_panel('lsx_currencies', array(
419 419
 			'priority'          => 62,
420 420
 			'capability'        => 'edit_theme_options',
421 421
 			'theme_supports'    => '',
422
-			'title'             => esc_html__( 'Currencies', 'lsx-currencies' ),
423
-			'description'       => esc_html__( 'LSX Currencies extension settings.', 'lsx-currencies' ),
424
-		) );
422
+			'title'             => esc_html__('Currencies', 'lsx-currencies'),
423
+			'description'       => esc_html__('LSX Currencies extension settings.', 'lsx-currencies'),
424
+		));
425 425
 
426 426
 		/**
427 427
 		 * Section.
428 428
 		 */
429 429
 
430
-		$wp_customize->add_section( 'lsx_currencies_display', array(
431
-			'title'       => esc_html__( 'Display', 'lsx-currencies' ),
432
-			'description' => esc_html__( 'LSX Currencies extension display settings.', 'lsx-currencies' ),
430
+		$wp_customize->add_section('lsx_currencies_display', array(
431
+			'title'       => esc_html__('Display', 'lsx-currencies'),
432
+			'description' => esc_html__('LSX Currencies extension display settings.', 'lsx-currencies'),
433 433
 			'panel'       => 'lsx_currencies',
434 434
 			'priority'    => 1,
435
-		) );
435
+		));
436 436
 
437 437
 		/**
438 438
 		 * Fields.
439 439
 		 */
440 440
 
441
-		$wp_customize->add_setting( 'lsx_currencies_currency_menu_position', array(
441
+		$wp_customize->add_setting('lsx_currencies_currency_menu_position', array(
442 442
 			'default' => '',
443
-			'sanitize_callback' => array( '\lsx\currencies\classes\Currencies', 'sanitize_select' ),
444
-		) );
443
+			'sanitize_callback' => array('\lsx\currencies\classes\Currencies', 'sanitize_select'),
444
+		));
445 445
 
446 446
 		$choices = array(
447
-			'' => esc_html__( 'None', 'lsx-currencies' ),
447
+			'' => esc_html__('None', 'lsx-currencies'),
448 448
 		);
449 449
 
450 450
 		$menus = get_registered_nav_menus();
451 451
 
452
-		if ( is_array( $menus ) && ! empty( $menus ) ) {
453
-			$choices = array_merge( $choices, $menus );
452
+		if (is_array($menus) && !empty($menus)) {
453
+			$choices = array_merge($choices, $menus);
454 454
 		}
455 455
 
456
-		$wp_customize->add_control( new \WP_Customize_Control( $wp_customize, 'lsx_currencies_currency_menu_position', array(
457
-			'label'       => esc_html__( 'Display in Menu', 'lsx-currencies' ),
458
-			'description' => esc_html__( 'Select the menu to display the currency menu switcher.', 'lsx-currencies' ),
456
+		$wp_customize->add_control(new \WP_Customize_Control($wp_customize, 'lsx_currencies_currency_menu_position', array(
457
+			'label'       => esc_html__('Display in Menu', 'lsx-currencies'),
458
+			'description' => esc_html__('Select the menu to display the currency menu switcher.', 'lsx-currencies'),
459 459
 			'section'     => 'lsx_currencies_display',
460 460
 			'settings'    => 'lsx_currencies_currency_menu_position',
461 461
 			'type'        => 'select',
462 462
 			'priority'    => 1,
463 463
 			'choices'     => $choices,
464
-		) ) );
464
+		)));
465 465
 
466
-		$wp_customize->add_setting( 'lsx_currencies_display_flags', array(
466
+		$wp_customize->add_setting('lsx_currencies_display_flags', array(
467 467
 			'default'           => false,
468
-			'sanitize_callback' => array( '\lsx\currencies\classes\Currencies', 'sanitize_checkbox' ),
469
-		) );
468
+			'sanitize_callback' => array('\lsx\currencies\classes\Currencies', 'sanitize_checkbox'),
469
+		));
470 470
 
471
-		$wp_customize->add_control( new \WP_Customize_Control( $wp_customize, 'lsx_currencies_display_flags', array(
472
-			'label'       => esc_html__( 'Display Flags', 'lsx-currencies' ),
473
-			'description' => esc_html__( 'Displays a small flag in front of the name.', 'lsx-currencies' ),
471
+		$wp_customize->add_control(new \WP_Customize_Control($wp_customize, 'lsx_currencies_display_flags', array(
472
+			'label'       => esc_html__('Display Flags', 'lsx-currencies'),
473
+			'description' => esc_html__('Displays a small flag in front of the name.', 'lsx-currencies'),
474 474
 			'section'     => 'lsx_currencies_display',
475 475
 			'settings'    => 'lsx_currencies_display_flags',
476 476
 			'type'        => 'checkbox',
477 477
 			'priority'    => 2,
478
-		) ) );
478
+		)));
479 479
 
480
-		$wp_customize->add_setting( 'lsx_currencies_flag_position', array(
480
+		$wp_customize->add_setting('lsx_currencies_flag_position', array(
481 481
 			'default'           => 'left',
482
-			'sanitize_callback' => array( '\lsx\currencies\classes\Currencies', 'sanitize_select' ),
483
-		) );
482
+			'sanitize_callback' => array('\lsx\currencies\classes\Currencies', 'sanitize_select'),
483
+		));
484 484
 
485
-		$wp_customize->add_control( new \WP_Customize_Control( $wp_customize, 'lsx_currencies_flag_position', array(
486
-			'label'       => esc_html__( 'Flag Position', 'lsx-currencies' ),
487
-			'description' => esc_html__( 'This moves the flag to the right (after the symbol).', 'lsx-currencies' ),
485
+		$wp_customize->add_control(new \WP_Customize_Control($wp_customize, 'lsx_currencies_flag_position', array(
486
+			'label'       => esc_html__('Flag Position', 'lsx-currencies'),
487
+			'description' => esc_html__('This moves the flag to the right (after the symbol).', 'lsx-currencies'),
488 488
 			'section'     => 'lsx_currencies_display',
489 489
 			'settings'    => 'lsx_currencies_flag_position',
490 490
 			'type'        => 'select',
491 491
 			'priority'    => 3,
492 492
 			'choices'     => array(
493
-				'left' => esc_html__( 'Left', 'lsx-currencies' ),
494
-				'right' => esc_html__( 'Right', 'lsx-currencies' ),
493
+				'left' => esc_html__('Left', 'lsx-currencies'),
494
+				'right' => esc_html__('Right', 'lsx-currencies'),
495 495
 			),
496
-		) ) );
496
+		)));
497 497
 
498
-		$wp_customize->add_setting( 'lsx_currencies_currency_switcher_position', array(
498
+		$wp_customize->add_setting('lsx_currencies_currency_switcher_position', array(
499 499
 			'default'           => 'right',
500
-			'sanitize_callback' => array( '\lsx\currencies\classes\Currencies', 'sanitize_select' ),
501
-		) );
500
+			'sanitize_callback' => array('\lsx\currencies\classes\Currencies', 'sanitize_select'),
501
+		));
502 502
 
503
-		$wp_customize->add_control( new \WP_Customize_Control( $wp_customize, 'lsx_currencies_currency_switcher_position', array(
504
-			'label'       => esc_html__( 'Symbol Position', 'lsx-currencies' ),
505
-			'description' => esc_html__( 'This moves the symbol for the switcher to the left (before the flag).', 'lsx-currencies' ),
503
+		$wp_customize->add_control(new \WP_Customize_Control($wp_customize, 'lsx_currencies_currency_switcher_position', array(
504
+			'label'       => esc_html__('Symbol Position', 'lsx-currencies'),
505
+			'description' => esc_html__('This moves the symbol for the switcher to the left (before the flag).', 'lsx-currencies'),
506 506
 			'section'     => 'lsx_currencies_display',
507 507
 			'settings'    => 'lsx_currencies_currency_switcher_position',
508 508
 			'type'        => 'select',
509 509
 			'priority'    => 4,
510 510
 			'choices'     => array(
511
-				'left' => esc_html__( 'Left', 'lsx-currencies' ),
512
-				'right' => esc_html__( 'Right', 'lsx-currencies' ),
511
+				'left' => esc_html__('Left', 'lsx-currencies'),
512
+				'right' => esc_html__('Right', 'lsx-currencies'),
513 513
 			),
514
-		) ) );
514
+		)));
515 515
 	}
516 516
 }
Please login to merge, or discard this patch.
classes/class-frontend.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 	 * Constructor
49 49
 	 */
50 50
 	public function __construct() {
51
-		if ( ! is_admin() ) {
52
-			add_action( 'plugins_loaded', array( $this, 'set_defaults' ), 11, 1 );
53
-			add_filter( 'lsx_to_custom_field_query', array( $this, 'price_filter' ), 20, 5 );
54
-			add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 );
55
-			add_filter( 'wp_nav_menu_items', array( $this, 'wp_nav_menu_items_filter' ), 10, 2 );
56
-			add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 );
57
-			add_filter( 'get_post_metadata', array( $this, 'filter_post_meta' ), 100, 4 );
51
+		if (!is_admin()) {
52
+			add_action('plugins_loaded', array($this, 'set_defaults'), 11, 1);
53
+			add_filter('lsx_to_custom_field_query', array($this, 'price_filter'), 20, 5);
54
+			add_action('wp_enqueue_scripts', array($this, 'assets'), 5);
55
+			add_filter('wp_nav_menu_items', array($this, 'wp_nav_menu_items_filter'), 10, 2);
56
+			add_filter('wp_kses_allowed_html', array($this, 'wp_kses_allowed_html'), 10, 2);
57
+			add_filter('get_post_metadata', array($this, 'filter_post_meta'), 100, 4);
58 58
 		}
59 59
 	}
60 60
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public static function init() {
67 67
 		// If the single instance hasn't been set, set it now.
68
-		if ( ! isset( self::$instance ) ) {
68
+		if (!isset(self::$instance)) {
69 69
 			self::$instance = new self();
70 70
 		}
71 71
 		return self::$instance;
@@ -75,56 +75,56 @@  discard block
 block discarded – undo
75 75
 	 * Constructor
76 76
 	 */
77 77
 	public function set_defaults() {
78
-		$this->rates_message = esc_html__( 'Error: API key isn\'t set.', 'lsx-currencies' );
79
-		$this->rates = get_transient( 'lsx_currencies_rates' );
80
-		if ( false === $this->rates ) {
81
-			$rates         = wp_remote_retrieve_body( wp_safe_remote_get( lsx_currencies()->api_url ) );
82
-			$decoded_rates = json_decode( $rates );
78
+		$this->rates_message = esc_html__('Error: API key isn\'t set.', 'lsx-currencies');
79
+		$this->rates = get_transient('lsx_currencies_rates');
80
+		if (false === $this->rates) {
81
+			$rates         = wp_remote_retrieve_body(wp_safe_remote_get(lsx_currencies()->api_url));
82
+			$decoded_rates = json_decode($rates);
83 83
 
84
-			if ( is_wp_error( $rates ) ) {
84
+			if (is_wp_error($rates)) {
85 85
 				$this->rates_message = $rates->get_error_message();
86
-			} elseif ( ! empty( $decoded_rates->error ) ) {
86
+			} elseif (!empty($decoded_rates->error)) {
87 87
 				$this->rates_message = $decoded_rates->description;
88
-			} elseif ( empty( $rates ) ) {
89
-				$this->rates_message = esc_html__( 'Error: API response is empty.', 'lsx-currencies' );
88
+			} elseif (empty($rates)) {
89
+				$this->rates_message = esc_html__('Error: API response is empty.', 'lsx-currencies');
90 90
 			} else {
91
-				$this->rates_message = esc_html__( 'Success (new request).', 'lsx-currencies' );
92
-				set_transient( 'lsx_currencies_rates', $decoded_rates->rates, 60 * 60 * 12 );
93
-				do_action( 'lsx_currencies_rates_refreshed' );
91
+				$this->rates_message = esc_html__('Success (new request).', 'lsx-currencies');
92
+				set_transient('lsx_currencies_rates', $decoded_rates->rates, 60 * 60 * 12);
93
+				do_action('lsx_currencies_rates_refreshed');
94 94
 				$this->rates = $decoded_rates->rates;
95 95
 			}
96 96
 		} else {
97
-			$this->rates_message = esc_html__( 'Success (from cache).', 'lsx-currencies' );
97
+			$this->rates_message = esc_html__('Success (from cache).', 'lsx-currencies');
98 98
 		}
99
-		$this->current_currency = isset( $_COOKIE['lsx_currencies_choice'] ) ? sanitize_key( $_COOKIE['lsx_currencies_choice'] ) : lsx_currencies()->base_currency;
100
-		$this->current_currency = strtoupper( $this->current_currency );
99
+		$this->current_currency = isset($_COOKIE['lsx_currencies_choice']) ? sanitize_key($_COOKIE['lsx_currencies_choice']) : lsx_currencies()->base_currency;
100
+		$this->current_currency = strtoupper($this->current_currency);
101 101
 	}
102 102
 
103 103
 	/**
104 104
 	 * Enques the assets
105 105
 	 */
106 106
 	public function assets() {
107
-		wp_enqueue_script( 'lsx-moneyjs', LSX_CURRENCIES_URL . 'assets/js/vendor/money.min.js', array( 'jquery' ), LSX_CURRENCIES_VER, true );
108
-		wp_enqueue_script( 'lsx-accountingjs', LSX_CURRENCIES_URL . 'assets/js/vendor/accounting.min.js', array( 'jquery' ), LSX_CURRENCIES_VER, true );
109
-		wp_enqueue_script( 'lsx-jquery-cookie', LSX_CURRENCIES_URL . 'assets/js/vendor/cookie.min.js', array( 'jquery' ), LSX_CURRENCIES_VER, true );
107
+		wp_enqueue_script('lsx-moneyjs', LSX_CURRENCIES_URL.'assets/js/vendor/money.min.js', array('jquery'), LSX_CURRENCIES_VER, true);
108
+		wp_enqueue_script('lsx-accountingjs', LSX_CURRENCIES_URL.'assets/js/vendor/accounting.min.js', array('jquery'), LSX_CURRENCIES_VER, true);
109
+		wp_enqueue_script('lsx-jquery-cookie', LSX_CURRENCIES_URL.'assets/js/vendor/cookie.min.js', array('jquery'), LSX_CURRENCIES_VER, true);
110 110
 
111 111
 		$prefix = '.min';
112 112
 		$src = '';
113 113
 		$script_debug = false;
114
-		if ( defined( 'SCRIPT_DEBUG' ) ) {
114
+		if (defined('SCRIPT_DEBUG')) {
115 115
 			$prefix = '';
116 116
 			$src = 'src/';
117 117
 			$script_debug = true;
118 118
 		}
119
-		wp_enqueue_script( 'lsx-currencies', LSX_CURRENCIES_URL . 'assets/js/' . $src . 'lsx-currencies' . $prefix . '.js', array( 'jquery', 'lsx-moneyjs', 'lsx-accountingjs', 'lsx-jquery-cookie' ), LSX_CURRENCIES_VER, true );
119
+		wp_enqueue_script('lsx-currencies', LSX_CURRENCIES_URL.'assets/js/'.$src.'lsx-currencies'.$prefix.'.js', array('jquery', 'lsx-moneyjs', 'lsx-accountingjs', 'lsx-jquery-cookie'), LSX_CURRENCIES_VER, true);
120 120
 
121 121
 		$base_currency = lsx_currencies()->base_currency;
122 122
 		$current_currency = $this->current_currency;
123
-		if ( true === lsx_currencies()->convert_to_single ) {
123
+		if (true === lsx_currencies()->convert_to_single) {
124 124
 			$current_currency = $base_currency;
125 125
 		}
126 126
 
127
-		$params = apply_filters( 'lsx_currencies_js_params', array(
127
+		$params = apply_filters('lsx_currencies_js_params', array(
128 128
 			'current_currency'  => $current_currency,
129 129
 			'currency_symbols'  => $this->get_available_symbols(),
130 130
 			'rates'             => $this->rates,
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
 			'remove_decimals'   => lsx_currencies()->remove_decimals,
137 137
 		));
138 138
 
139
-		wp_localize_script( 'lsx-currencies', 'lsx_currencies_params', $params );
139
+		wp_localize_script('lsx-currencies', 'lsx_currencies_params', $params);
140 140
 
141
-		wp_enqueue_style( 'lsx-currencies', LSX_CURRENCIES_URL . 'assets/css/lsx-currencies.css', array(), LSX_CURRENCIES_VER );
142
-		wp_style_add_data( 'lsx-currencies', 'rtl', 'replace' );
141
+		wp_enqueue_style('lsx-currencies', LSX_CURRENCIES_URL.'assets/css/lsx-currencies.css', array(), LSX_CURRENCIES_VER);
142
+		wp_style_add_data('lsx-currencies', 'rtl', 'replace');
143 143
 	}
144 144
 
145 145
 	/**
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function get_available_symbols() {
151 151
 		$symbols = array();
152
-		if ( false !== lsx_currencies()->additional_currencies && ! empty( lsx_currencies()->additional_currencies ) ) {
153
-			foreach ( lsx_currencies()->additional_currencies as $key => $currency ) {
154
-				$symbols[ $key ] = lsx_currencies()->currency_symbols[ $key ];
152
+		if (false !== lsx_currencies()->additional_currencies && !empty(lsx_currencies()->additional_currencies)) {
153
+			foreach (lsx_currencies()->additional_currencies as $key => $currency) {
154
+				$symbols[$key] = lsx_currencies()->currency_symbols[$key];
155 155
 			}
156 156
 		}
157 157
 		return $symbols;
@@ -160,63 +160,63 @@  discard block
 block discarded – undo
160 160
 	/**
161 161
 	 * Adds in the required currency conversion tags
162 162
 	 */
163
-	public function price_filter( $return_html, $meta_key, $value, $before, $after ) {
164
-		if ( 'price' === $meta_key ) {
163
+	public function price_filter($return_html, $meta_key, $value, $before, $after) {
164
+		if ('price' === $meta_key) {
165 165
 			$additional_html = '';
166
-			$additional_prices = get_post_meta( get_the_ID(), 'additional_prices', false );
166
+			$additional_prices = get_post_meta(get_the_ID(), 'additional_prices', false);
167 167
 			$prefix = '<span class="amount lsx-currencies" ';
168 168
 
169
-			if ( true === lsx_currencies()->multi_prices && ! empty( $additional_prices ) ) {
170
-				foreach ( $additional_prices as $a_price ) {
171
-					$additional_html .= ' data-price-' . $a_price['currency'] . '="' . $a_price['amount'] . '"';
169
+			if (true === lsx_currencies()->multi_prices && !empty($additional_prices)) {
170
+				foreach ($additional_prices as $a_price) {
171
+					$additional_html .= ' data-price-'.$a_price['currency'].'="'.$a_price['amount'].'"';
172 172
 				}
173 173
 			}
174 174
 
175
-			$value = preg_replace( '/[^0-9.]+/', '', $value );
176
-			$decimals = substr_count( $value, '.' );
175
+			$value = preg_replace('/[^0-9.]+/', '', $value);
176
+			$decimals = substr_count($value, '.');
177 177
 
178
-			if ( false !== $decimals && $decimals > 1 ) {
178
+			if (false !== $decimals && $decimals > 1) {
179 179
 				$decimals--;
180 180
 				$decimals = (int) $decimals;
181
-				$value = preg_replace( '/' . preg_quote( '.', '/' ) . '/', '', $value, $decimals );
181
+				$value = preg_replace('/'.preg_quote('.', '/').'/', '', $value, $decimals);
182 182
 			}
183 183
 
184 184
 			$money_format = '%i';
185
-			if ( false !== lsx_currencies()->remove_decimals ) {
185
+			if (false !== lsx_currencies()->remove_decimals) {
186 186
 				$money_format = '%.0n';
187 187
 			}
188 188
 
189 189
 			$prefix .= '>';
190 190
 			$suffix = '</span>';
191 191
 
192
-			setlocale( LC_MONETARY, 'en_US' );
192
+			setlocale(LC_MONETARY, 'en_US');
193 193
 
194 194
 			// Work out the other tags
195
-			$currency = '<span class="currency-icon ' . mb_strtolower( lsx_currencies()->base_currency ) . '">' . lsx_currencies()->base_currency . '</span>';
196
-			$amount = '<span class="value" data-price-' . lsx_currencies()->base_currency . '="' . trim( str_replace( array( '$', 'USD' ), '', money_format( (float) $money_format, ltrim( rtrim( $value ) ) ) ) ) . '" ' . $additional_html . '>' . str_replace( array( '$', 'USD' ), '', money_format( $money_format, ltrim( rtrim( $value ) ) ) ) . '</span>';
195
+			$currency = '<span class="currency-icon '.mb_strtolower(lsx_currencies()->base_currency).'">'.lsx_currencies()->base_currency.'</span>';
196
+			$amount = '<span class="value" data-price-'.lsx_currencies()->base_currency.'="'.trim(str_replace(array('$', 'USD'), '', money_format((float) $money_format, ltrim(rtrim($value))))).'" '.$additional_html.'>'.str_replace(array('$', 'USD'), '', money_format($money_format, ltrim(rtrim($value)))).'</span>';
197 197
 
198 198
 			// Check for a price type and add that in.
199
-			$price_type = get_post_meta( get_the_ID(), 'price_type', true );
199
+			$price_type = get_post_meta(get_the_ID(), 'price_type', true);
200 200
 
201
-			switch ( $price_type ) {
201
+			switch ($price_type) {
202 202
 				case 'per_person_per_night':
203 203
 				case 'per_person_sharing':
204 204
 				case 'per_person_sharing_per_night':
205
-					$amount = $currency . $amount . ' ' . ucwords( str_replace( '_', ' ', $price_type ) );
205
+					$amount = $currency.$amount.' '.ucwords(str_replace('_', ' ', $price_type));
206 206
 				    break;
207 207
 
208 208
 				case 'total_percentage':
209
-					$amount .= '% ' . esc_html__( 'Off', 'lsx-currencies' );
210
-					$before = str_replace( 'from', '', $before );
209
+					$amount .= '% '.esc_html__('Off', 'lsx-currencies');
210
+					$before = str_replace('from', '', $before);
211 211
 				    break;
212 212
 
213 213
 				case 'none':
214 214
 				default:
215
-					$amount = $currency . $amount;
215
+					$amount = $currency.$amount;
216 216
 				    break;
217 217
 			}
218 218
 
219
-			$return_html = $before . $prefix . $amount . $suffix . $after;
219
+			$return_html = $before.$prefix.$amount.$suffix.$after;
220 220
 		}
221 221
 
222 222
 		return $return_html;
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @return string
232 232
 	 */
233
-	public function wp_nav_menu_items_filter( $items, $args ) {
234
-		if ( '' !== lsx_currencies()->menus && lsx_currencies()->menus === $args->theme_location ) {
235
-			if ( 'top-menu' === $args->theme_location ) {
236
-				$items = $this->get_menu_html( $args ) . $items;
233
+	public function wp_nav_menu_items_filter($items, $args) {
234
+		if ('' !== lsx_currencies()->menus && lsx_currencies()->menus === $args->theme_location) {
235
+			if ('top-menu' === $args->theme_location) {
236
+				$items = $this->get_menu_html($args).$items;
237 237
 			} else {
238
-				$items = $items . $this->get_menu_html( $args );
238
+				$items = $items.$this->get_menu_html($args);
239 239
 			}
240 240
 		}
241 241
 		return $items;
@@ -248,38 +248,38 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return string
250 250
 	 */
251
-	private function get_menu_html( $args ) {
252
-		if ( empty( lsx_currencies()->additional_currencies ) ) {
251
+	private function get_menu_html($args) {
252
+		if (empty(lsx_currencies()->additional_currencies)) {
253 253
 			return '';
254 254
 		}
255 255
 
256 256
 		$items = '';
257 257
 		$items .= '<li class="menu-item menu-item-currency menu-item-currency-current menu-item-has-children dropdown">';
258
-		$items .= isset( $args->before ) ? $args->before : '';
259
-		$items .= '<a class="current symbol-' . lsx_currencies()->switcher_symbol_position . '" href="#' . strtolower( $this->current_currency ) . '">';
260
-		$items .= isset( $args->link_before ) ? $args->link_before : '';
258
+		$items .= isset($args->before) ? $args->before : '';
259
+		$items .= '<a class="current symbol-'.lsx_currencies()->switcher_symbol_position.'" href="#'.strtolower($this->current_currency).'">';
260
+		$items .= isset($args->link_before) ? $args->link_before : '';
261 261
 
262
-		if ( ! empty( lsx_currencies()->display_flags ) && 'left' === lsx_currencies()->flag_position ) {
263
-			$items .= lsx_currencies()->get_currency_flag( $this->current_currency );
262
+		if (!empty(lsx_currencies()->display_flags) && 'left' === lsx_currencies()->flag_position) {
263
+			$items .= lsx_currencies()->get_currency_flag($this->current_currency);
264 264
 		}
265 265
 
266
-		if ( 'left' === lsx_currencies()->switcher_symbol_position ) {
267
-			$items .= '<span class="currency-icon ' . strtolower( $this->current_currency ) . '"></span>';
266
+		if ('left' === lsx_currencies()->switcher_symbol_position) {
267
+			$items .= '<span class="currency-icon '.strtolower($this->current_currency).'"></span>';
268 268
 		}
269 269
 
270 270
 		$items .= $this->current_currency;
271 271
 
272
-		if ( 'right' === lsx_currencies()->switcher_symbol_position ) {
273
-			$items .= '<span class="currency-icon ' . strtolower( $this->current_currency ) . '"></span>';
272
+		if ('right' === lsx_currencies()->switcher_symbol_position) {
273
+			$items .= '<span class="currency-icon '.strtolower($this->current_currency).'"></span>';
274 274
 		}
275 275
 
276
-		if ( ! empty( lsx_currencies()->display_flags ) && 'right' === lsx_currencies()->flag_position ) {
277
-			$items .= lsx_currencies()->get_currency_flag( $this->current_currency );
276
+		if (!empty(lsx_currencies()->display_flags) && 'right' === lsx_currencies()->flag_position) {
277
+			$items .= lsx_currencies()->get_currency_flag($this->current_currency);
278 278
 		}
279 279
 
280
-		$items .= isset( $args->link_after ) ? $args->link_after : '';
280
+		$items .= isset($args->link_after) ? $args->link_after : '';
281 281
 		$items .= '<span class="caret"></span></a>';
282
-		$items .= isset( $args->after ) ? $args->after : '';
282
+		$items .= isset($args->after) ? $args->after : '';
283 283
 		$items .= $this->render_sub_items();
284 284
 		$items .= '</li>';
285 285
 		return $items;
@@ -293,48 +293,48 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	private function render_sub_items() {
295 295
 		$sub_items = '';
296
-		foreach ( lsx_currencies()->additional_currencies as $key => $currency ) {
296
+		foreach (lsx_currencies()->additional_currencies as $key => $currency) {
297 297
 			$hidden = '';
298 298
 			$class = '';
299 299
 
300
-			if ( $this->current_currency === $key ) {
300
+			if ($this->current_currency === $key) {
301 301
 				$hidden = 'style="display:none";';
302 302
 				$class = 'hidden';
303 303
 			}
304 304
 
305
-			$sub_items .= '<li ' . $hidden . ' class="' . $class . ' menu-item menu-item-currency ' . lsx_currencies()->switcher_symbol_position . '">';
306
-			$sub_items .= '<a class=" symbol-' . lsx_currencies()->switcher_symbol_position . '" href="#' . strtolower( $key ) . '">';
305
+			$sub_items .= '<li '.$hidden.' class="'.$class.' menu-item menu-item-currency '.lsx_currencies()->switcher_symbol_position.'">';
306
+			$sub_items .= '<a class=" symbol-'.lsx_currencies()->switcher_symbol_position.'" href="#'.strtolower($key).'">';
307 307
 
308
-			if ( ! empty( lsx_currencies()->display_flags ) && 'left' === lsx_currencies()->flag_position ) {
309
-				$sub_items .= lsx_currencies()->get_currency_flag( $key );
308
+			if (!empty(lsx_currencies()->display_flags) && 'left' === lsx_currencies()->flag_position) {
309
+				$sub_items .= lsx_currencies()->get_currency_flag($key);
310 310
 			}
311 311
 
312
-			if ( 'left' === lsx_currencies()->switcher_symbol_position ) {
313
-				$sub_items .= '<span class="currency-icon ' . strtolower( $key ) . '"></span>';
312
+			if ('left' === lsx_currencies()->switcher_symbol_position) {
313
+				$sub_items .= '<span class="currency-icon '.strtolower($key).'"></span>';
314 314
 			}
315 315
 
316
-			$sub_items .= ucwords( $key );
316
+			$sub_items .= ucwords($key);
317 317
 
318
-			if ( 'right' === lsx_currencies()->switcher_symbol_position ) {
319
-				$sub_items .= '<span class="currency-icon ' . strtolower( $key ) . '"></span>';
318
+			if ('right' === lsx_currencies()->switcher_symbol_position) {
319
+				$sub_items .= '<span class="currency-icon '.strtolower($key).'"></span>';
320 320
 			}
321 321
 
322
-			if ( ! empty( lsx_currencies()->display_flags ) && 'right' === lsx_currencies()->flag_position ) {
323
-				$sub_items .= lsx_currencies()->get_currency_flag( $key );
322
+			if (!empty(lsx_currencies()->display_flags) && 'right' === lsx_currencies()->flag_position) {
323
+				$sub_items .= lsx_currencies()->get_currency_flag($key);
324 324
 			}
325 325
 
326 326
 			$sub_items .= '</a></li>';
327 327
 		}
328 328
 
329
-		$sub_items = '<ul class="sub-menu submenu-currency dropdown-menu">' . $sub_items . '</ul>';
329
+		$sub_items = '<ul class="sub-menu submenu-currency dropdown-menu">'.$sub_items.'</ul>';
330 330
 		return $sub_items;
331 331
 	}
332 332
 
333 333
 	/**
334 334
 	 * Allow data params for Slick slider addon.
335 335
 	 */
336
-	public function wp_kses_allowed_html( $allowedtags, $context ) {
337
-		if ( ! isset( $allowedtags['span'] ) ) {
336
+	public function wp_kses_allowed_html($allowedtags, $context) {
337
+		if (!isset($allowedtags['span'])) {
338 338
 			$allowedtags['span'] = array();
339 339
 		}
340 340
 
@@ -381,11 +381,11 @@  discard block
 block discarded – undo
381 381
 	 * @param boolean $single
382 382
 	 * @return void
383 383
 	 */
384
-	public function filter_post_meta( $metadata = null, $object_id, $meta_key, $single ) {
385
-		if ( true === lsx_currencies()->convert_to_single && 'price' === $meta_key ) {
386
-			$meta_cache = wp_cache_get( $object_id, 'post_meta' );
384
+	public function filter_post_meta($metadata = null, $object_id, $meta_key, $single) {
385
+		if (true === lsx_currencies()->convert_to_single && 'price' === $meta_key) {
386
+			$meta_cache = wp_cache_get($object_id, 'post_meta');
387 387
 
388
-			if ( ! isset( $meta_cache[ $meta_key ] ) || '' === $meta_cache[ $meta_key ] ) {
388
+			if (!isset($meta_cache[$meta_key]) || '' === $meta_cache[$meta_key]) {
389 389
 				$metadata = '0';
390 390
 			}
391 391
 		}
Please login to merge, or discard this patch.