@@ -13,17 +13,17 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // If this file is called directly, abort. |
| 16 | -if ( ! defined( 'WPINC' ) ) { |
|
| 16 | +if (!defined('WPINC')) { |
|
| 17 | 17 | die; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -define( 'LSX_CURRENCIES_PATH', plugin_dir_path( __FILE__ ) ); |
|
| 21 | -define( 'LSX_CURRENCIES_CORE', __FILE__ ); |
|
| 22 | -define( 'LSX_CURRENCIES_URL', plugin_dir_url( __FILE__ ) ); |
|
| 23 | -define( 'LSX_CURRENCIES_VER', '1.2.5' ); |
|
| 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.5'); |
|
| 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 |
@@ -16,106 +16,106 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class FacetWP { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Holds instance of the class |
|
| 21 | - * |
|
| 22 | - * @var object \lsx\currencies\classes\FacetWP() |
|
| 23 | - */ |
|
| 24 | - private static $instance; |
|
| 19 | + /** |
|
| 20 | + * Holds instance of the class |
|
| 21 | + * |
|
| 22 | + * @var object \lsx\currencies\classes\FacetWP() |
|
| 23 | + */ |
|
| 24 | + private static $instance; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Holds the current currency. |
|
| 28 | - * |
|
| 29 | - * @var boolean |
|
| 30 | - */ |
|
| 31 | - public $currency = false; |
|
| 26 | + /** |
|
| 27 | + * Holds the current currency. |
|
| 28 | + * |
|
| 29 | + * @var boolean |
|
| 30 | + */ |
|
| 31 | + public $currency = false; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor |
|
| 35 | - */ |
|
| 36 | - public function __construct() { |
|
| 37 | - add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 20, 2 ); |
|
| 38 | - add_action( 'lsx_currencies_rates_refreshed', array( $this, 'refresh_the_currencies' ), 20 ); |
|
| 39 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor |
|
| 35 | + */ |
|
| 36 | + public function __construct() { |
|
| 37 | + add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 20, 2 ); |
|
| 38 | + add_action( 'lsx_currencies_rates_refreshed', array( $this, 'refresh_the_currencies' ), 20 ); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Return an instance of this class. |
|
| 43 | - * |
|
| 44 | - * @return object |
|
| 45 | - */ |
|
| 46 | - public static function init() { |
|
| 47 | - // If the single instance hasn't been set, set it now. |
|
| 48 | - if ( ! isset( self::$instance ) ) { |
|
| 49 | - self::$instance = new self(); |
|
| 50 | - } |
|
| 51 | - return self::$instance; |
|
| 52 | - } |
|
| 41 | + /** |
|
| 42 | + * Return an instance of this class. |
|
| 43 | + * |
|
| 44 | + * @return object |
|
| 45 | + */ |
|
| 46 | + public static function init() { |
|
| 47 | + // If the single instance hasn't been set, set it now. |
|
| 48 | + if ( ! isset( self::$instance ) ) { |
|
| 49 | + self::$instance = new self(); |
|
| 50 | + } |
|
| 51 | + return self::$instance; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Alter the rows and include extra facets rows for the continents. |
|
| 56 | - */ |
|
| 57 | - public function facetwp_index_row_data( $rows, $params ) { |
|
| 58 | - switch ( $params['facet']['source'] ) { |
|
| 59 | - case 'cf/price': |
|
| 60 | - // only convert a price to the base currency if the setting is active. |
|
| 61 | - // If $rows is empty then there is no base currency set. |
|
| 62 | - if ( true === lsx_currencies()->convert_to_single && empty( $rows ) ) { |
|
| 63 | - lsx_currencies()->frontend->set_defaults(); |
|
| 64 | - $additional_prices = get_post_meta( $params['defaults']['post_id'], 'additional_prices', false ); |
|
| 54 | + /** |
|
| 55 | + * Alter the rows and include extra facets rows for the continents. |
|
| 56 | + */ |
|
| 57 | + public function facetwp_index_row_data( $rows, $params ) { |
|
| 58 | + switch ( $params['facet']['source'] ) { |
|
| 59 | + case 'cf/price': |
|
| 60 | + // only convert a price to the base currency if the setting is active. |
|
| 61 | + // If $rows is empty then there is no base currency set. |
|
| 62 | + if ( true === lsx_currencies()->convert_to_single && empty( $rows ) ) { |
|
| 63 | + lsx_currencies()->frontend->set_defaults(); |
|
| 64 | + $additional_prices = get_post_meta( $params['defaults']['post_id'], 'additional_prices', false ); |
|
| 65 | 65 | |
| 66 | - if ( ! empty( $additional_prices ) && isset( $additional_prices[0] ) && ! empty( $additional_prices[0] ) && ! empty( lsx_currencies()->frontend->rates ) ) { |
|
| 67 | - $row_currency = $additional_prices[0]['currency']; |
|
| 68 | - $row_value = $additional_prices[0]['amount']; |
|
| 69 | - if ( '' !== $row_value && null !== $row_value ) { |
|
| 70 | - $current_currency = lsx_currencies()->frontend->current_currency; |
|
| 71 | - $usd_value = $row_value / lsx_currencies()->frontend->rates->$row_currency; |
|
| 72 | - if ( $row_currency !== $current_currency ) { |
|
| 73 | - $usd_value = $usd_value * lsx_currencies()->frontend->rates->$current_currency; |
|
| 74 | - } |
|
| 75 | - $new_row = $params['defaults']; |
|
| 76 | - $new_row['facet_value'] = round( $usd_value, 0 ); |
|
| 77 | - $new_row['facet_display_value'] = round( $usd_value, 0 ); |
|
| 78 | - $rows[] = $new_row; |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - break; |
|
| 66 | + if ( ! empty( $additional_prices ) && isset( $additional_prices[0] ) && ! empty( $additional_prices[0] ) && ! empty( lsx_currencies()->frontend->rates ) ) { |
|
| 67 | + $row_currency = $additional_prices[0]['currency']; |
|
| 68 | + $row_value = $additional_prices[0]['amount']; |
|
| 69 | + if ( '' !== $row_value && null !== $row_value ) { |
|
| 70 | + $current_currency = lsx_currencies()->frontend->current_currency; |
|
| 71 | + $usd_value = $row_value / lsx_currencies()->frontend->rates->$row_currency; |
|
| 72 | + if ( $row_currency !== $current_currency ) { |
|
| 73 | + $usd_value = $usd_value * lsx_currencies()->frontend->rates->$current_currency; |
|
| 74 | + } |
|
| 75 | + $new_row = $params['defaults']; |
|
| 76 | + $new_row['facet_value'] = round( $usd_value, 0 ); |
|
| 77 | + $new_row['facet_display_value'] = round( $usd_value, 0 ); |
|
| 78 | + $rows[] = $new_row; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + break; |
|
| 83 | 83 | |
| 84 | - default: |
|
| 85 | - break; |
|
| 86 | - } |
|
| 87 | - return $rows; |
|
| 88 | - } |
|
| 84 | + default: |
|
| 85 | + break; |
|
| 86 | + } |
|
| 87 | + return $rows; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * This will refresh the saved currencies that ar not the same as the base currency. |
|
| 92 | - * |
|
| 93 | - * @return void |
|
| 94 | - */ |
|
| 95 | - public function refresh_the_currencies() { |
|
| 96 | - if ( true === lsx_currencies()->convert_to_single ) { |
|
| 97 | - add_action( 'wp_footer', array( $this, 'trigger_the_index' ) ); |
|
| 98 | - } |
|
| 99 | - } |
|
| 90 | + /** |
|
| 91 | + * This will refresh the saved currencies that ar not the same as the base currency. |
|
| 92 | + * |
|
| 93 | + * @return void |
|
| 94 | + */ |
|
| 95 | + public function refresh_the_currencies() { |
|
| 96 | + if ( true === lsx_currencies()->convert_to_single ) { |
|
| 97 | + add_action( 'wp_footer', array( $this, 'trigger_the_index' ) ); |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Grabs the tour ids and runs them through the index. |
|
| 103 | - * |
|
| 104 | - * @return void |
|
| 105 | - */ |
|
| 106 | - public function trigger_the_index() { |
|
| 107 | - $tours_args = array( |
|
| 108 | - 'post_type' => 'tour', |
|
| 109 | - 'post_status' => 'publish', |
|
| 110 | - 'posts_per_page' => '-1', |
|
| 111 | - 'nopagin' => true, |
|
| 112 | - 'fields' => 'ids', |
|
| 113 | - ); |
|
| 114 | - $tours_query = new \WP_Query( $tours_args ); |
|
| 115 | - if ( $tours_query->have_posts() ) { |
|
| 116 | - foreach ( $tours_query->posts as $tour_id ) { |
|
| 117 | - FWP()->indexer->index( $tour_id ); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - } |
|
| 101 | + /** |
|
| 102 | + * Grabs the tour ids and runs them through the index. |
|
| 103 | + * |
|
| 104 | + * @return void |
|
| 105 | + */ |
|
| 106 | + public function trigger_the_index() { |
|
| 107 | + $tours_args = array( |
|
| 108 | + 'post_type' => 'tour', |
|
| 109 | + 'post_status' => 'publish', |
|
| 110 | + 'posts_per_page' => '-1', |
|
| 111 | + 'nopagin' => true, |
|
| 112 | + 'fields' => 'ids', |
|
| 113 | + ); |
|
| 114 | + $tours_query = new \WP_Query( $tours_args ); |
|
| 115 | + if ( $tours_query->have_posts() ) { |
|
| 116 | + foreach ( $tours_query->posts as $tour_id ) { |
|
| 117 | + FWP()->indexer->index( $tour_id ); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | 121 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * Constructor |
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | - add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 20, 2 ); |
|
| 38 | - add_action( 'lsx_currencies_rates_refreshed', array( $this, 'refresh_the_currencies' ), 20 ); |
|
| 37 | + add_filter('facetwp_indexer_row_data', array($this, 'facetwp_index_row_data'), 20, 2); |
|
| 38 | + add_action('lsx_currencies_rates_refreshed', array($this, 'refresh_the_currencies'), 20); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public static function init() { |
| 47 | 47 | // If the single instance hasn't been set, set it now. |
| 48 | - if ( ! isset( self::$instance ) ) { |
|
| 48 | + if (!isset(self::$instance)) { |
|
| 49 | 49 | self::$instance = new self(); |
| 50 | 50 | } |
| 51 | 51 | return self::$instance; |
@@ -54,27 +54,27 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * Alter the rows and include extra facets rows for the continents. |
| 56 | 56 | */ |
| 57 | - public function facetwp_index_row_data( $rows, $params ) { |
|
| 58 | - switch ( $params['facet']['source'] ) { |
|
| 57 | + public function facetwp_index_row_data($rows, $params) { |
|
| 58 | + switch ($params['facet']['source']) { |
|
| 59 | 59 | case 'cf/price': |
| 60 | 60 | // only convert a price to the base currency if the setting is active. |
| 61 | 61 | // If $rows is empty then there is no base currency set. |
| 62 | - if ( true === lsx_currencies()->convert_to_single && empty( $rows ) ) { |
|
| 62 | + if (true === lsx_currencies()->convert_to_single && empty($rows)) { |
|
| 63 | 63 | lsx_currencies()->frontend->set_defaults(); |
| 64 | - $additional_prices = get_post_meta( $params['defaults']['post_id'], 'additional_prices', false ); |
|
| 64 | + $additional_prices = get_post_meta($params['defaults']['post_id'], 'additional_prices', false); |
|
| 65 | 65 | |
| 66 | - if ( ! empty( $additional_prices ) && isset( $additional_prices[0] ) && ! empty( $additional_prices[0] ) && ! empty( lsx_currencies()->frontend->rates ) ) { |
|
| 66 | + if (!empty($additional_prices) && isset($additional_prices[0]) && !empty($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 | - if ( '' !== $row_value && null !== $row_value ) { |
|
| 69 | + if ('' !== $row_value && null !== $row_value) { |
|
| 70 | 70 | $current_currency = lsx_currencies()->frontend->current_currency; |
| 71 | 71 | $usd_value = $row_value / lsx_currencies()->frontend->rates->$row_currency; |
| 72 | - if ( $row_currency !== $current_currency ) { |
|
| 72 | + if ($row_currency !== $current_currency) { |
|
| 73 | 73 | $usd_value = $usd_value * lsx_currencies()->frontend->rates->$current_currency; |
| 74 | 74 | } |
| 75 | 75 | $new_row = $params['defaults']; |
| 76 | - $new_row['facet_value'] = round( $usd_value, 0 ); |
|
| 77 | - $new_row['facet_display_value'] = round( $usd_value, 0 ); |
|
| 76 | + $new_row['facet_value'] = round($usd_value, 0); |
|
| 77 | + $new_row['facet_display_value'] = round($usd_value, 0); |
|
| 78 | 78 | $rows[] = $new_row; |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | 95 | public function refresh_the_currencies() { |
| 96 | - if ( true === lsx_currencies()->convert_to_single ) { |
|
| 97 | - add_action( 'wp_footer', array( $this, 'trigger_the_index' ) ); |
|
| 96 | + if (true === lsx_currencies()->convert_to_single) { |
|
| 97 | + add_action('wp_footer', array($this, 'trigger_the_index')); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | * @return void |
| 105 | 105 | */ |
| 106 | 106 | public function trigger_the_index() { |
| 107 | - $tours_args = array( |
|
| 107 | + $tours_args = array( |
|
| 108 | 108 | 'post_type' => 'tour', |
| 109 | 109 | 'post_status' => 'publish', |
| 110 | 110 | 'posts_per_page' => '-1', |
| 111 | 111 | 'nopagin' => true, |
| 112 | 112 | 'fields' => 'ids', |
| 113 | 113 | ); |
| 114 | - $tours_query = new \WP_Query( $tours_args ); |
|
| 115 | - if ( $tours_query->have_posts() ) { |
|
| 116 | - foreach ( $tours_query->posts as $tour_id ) { |
|
| 117 | - FWP()->indexer->index( $tour_id ); |
|
| 114 | + $tours_query = new \WP_Query($tours_args); |
|
| 115 | + if ($tours_query->have_posts()) { |
|
| 116 | + foreach ($tours_query->posts as $tour_id) { |
|
| 117 | + FWP()->indexer->index($tour_id); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } |