@@ -9,6 +9,6 @@ |
||
9 | 9 | * Adds text domain. |
10 | 10 | */ |
11 | 11 | function lsx_search_load_plugin_textdomain() { |
12 | - load_plugin_textdomain( 'lsx-search', false, basename( LSX_SEARCH_PATH ) . '/languages' ); |
|
12 | + load_plugin_textdomain( 'lsx-search', false, basename( LSX_SEARCH_PATH ) . '/languages' ); |
|
13 | 13 | } |
14 | 14 | add_action( 'init', 'lsx_search_load_plugin_textdomain' ); |
@@ -9,6 +9,6 @@ |
||
9 | 9 | * Adds text domain. |
10 | 10 | */ |
11 | 11 | function lsx_search_load_plugin_textdomain() { |
12 | - load_plugin_textdomain( 'lsx-search', false, basename( LSX_SEARCH_PATH ) . '/languages' ); |
|
12 | + load_plugin_textdomain('lsx-search', false, basename(LSX_SEARCH_PATH).'/languages'); |
|
13 | 13 | } |
14 | -add_action( 'init', 'lsx_search_load_plugin_textdomain' ); |
|
14 | +add_action('init', 'lsx_search_load_plugin_textdomain'); |
@@ -13,17 +13,17 @@ discard block |
||
13 | 13 | * @return array |
14 | 14 | */ |
15 | 15 | function get_options() { |
16 | - $options = array(); |
|
17 | - if ( function_exists( 'tour_operator' ) ) { |
|
18 | - $options = get_option( '_lsx-to_settings', false ); |
|
19 | - } else { |
|
20 | - $options = get_option( '_lsx_settings', false ); |
|
16 | + $options = array(); |
|
17 | + if ( function_exists( 'tour_operator' ) ) { |
|
18 | + $options = get_option( '_lsx-to_settings', false ); |
|
19 | + } else { |
|
20 | + $options = get_option( '_lsx_settings', false ); |
|
21 | 21 | |
22 | - if ( false === $options ) { |
|
23 | - $options = get_option( '_lsx_lsx-settings', false ); |
|
24 | - } |
|
25 | - } |
|
26 | - return $options; |
|
22 | + if ( false === $options ) { |
|
23 | + $options = get_option( '_lsx_lsx-settings', false ); |
|
24 | + } |
|
25 | + } |
|
26 | + return $options; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -32,26 +32,26 @@ discard block |
||
32 | 32 | * @return array |
33 | 33 | */ |
34 | 34 | function get_restricted_post_types() { |
35 | - $post_types = array( |
|
36 | - 'page', |
|
37 | - 'attachment', |
|
38 | - 'lesson', |
|
39 | - 'certificate', |
|
40 | - 'envira', |
|
41 | - 'tribe_organizer', |
|
42 | - 'tribe_venue', |
|
43 | - 'envira', |
|
44 | - 'reply', |
|
45 | - 'topic', |
|
46 | - 'popup', |
|
47 | - 'question', |
|
48 | - 'certificate_template', |
|
49 | - 'sensei_message', |
|
50 | - 'tribe_events', |
|
51 | - 'tip', |
|
52 | - 'quiz', |
|
53 | - 'forum', |
|
54 | - ); |
|
55 | - $post_types = apply_filters( 'lsx_search_restricted_post_types', $post_types ); |
|
56 | - return $post_types; |
|
35 | + $post_types = array( |
|
36 | + 'page', |
|
37 | + 'attachment', |
|
38 | + 'lesson', |
|
39 | + 'certificate', |
|
40 | + 'envira', |
|
41 | + 'tribe_organizer', |
|
42 | + 'tribe_venue', |
|
43 | + 'envira', |
|
44 | + 'reply', |
|
45 | + 'topic', |
|
46 | + 'popup', |
|
47 | + 'question', |
|
48 | + 'certificate_template', |
|
49 | + 'sensei_message', |
|
50 | + 'tribe_events', |
|
51 | + 'tip', |
|
52 | + 'quiz', |
|
53 | + 'forum', |
|
54 | + ); |
|
55 | + $post_types = apply_filters( 'lsx_search_restricted_post_types', $post_types ); |
|
56 | + return $post_types; |
|
57 | 57 | } |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function get_options() { |
16 | 16 | $options = array(); |
17 | - if ( function_exists( 'tour_operator' ) ) { |
|
18 | - $options = get_option( '_lsx-to_settings', false ); |
|
17 | + if (function_exists('tour_operator')) { |
|
18 | + $options = get_option('_lsx-to_settings', false); |
|
19 | 19 | } else { |
20 | - $options = get_option( '_lsx_settings', false ); |
|
20 | + $options = get_option('_lsx_settings', false); |
|
21 | 21 | |
22 | - if ( false === $options ) { |
|
23 | - $options = get_option( '_lsx_lsx-settings', false ); |
|
22 | + if (false === $options) { |
|
23 | + $options = get_option('_lsx_lsx-settings', false); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 | return $options; |
@@ -52,6 +52,6 @@ discard block |
||
52 | 52 | 'quiz', |
53 | 53 | 'forum', |
54 | 54 | ); |
55 | - $post_types = apply_filters( 'lsx_search_restricted_post_types', $post_types ); |
|
55 | + $post_types = apply_filters('lsx_search_restricted_post_types', $post_types); |
|
56 | 56 | return $post_types; |
57 | 57 | } |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | // If this file is called directly, abort. |
15 | 15 | if ( ! defined( 'WPINC' ) ) { |
16 | - die; |
|
16 | + die; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | define( 'LSX_SEARCH_PATH', plugin_dir_path( __FILE__ ) ); |
@@ -12,17 +12,17 @@ |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // If this file is called directly, abort. |
15 | -if ( ! defined( 'WPINC' ) ) { |
|
15 | +if (!defined('WPINC')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
19 | -define( 'LSX_SEARCH_PATH', plugin_dir_path( __FILE__ ) ); |
|
20 | -define( 'LSX_SEARCH_CORE', __FILE__ ); |
|
21 | -define( 'LSX_SEARCH_URL', plugin_dir_url( __FILE__ ) ); |
|
22 | -define( 'LSX_SEARCH_VER', '1.5.2' ); |
|
19 | +define('LSX_SEARCH_PATH', plugin_dir_path(__FILE__)); |
|
20 | +define('LSX_SEARCH_CORE', __FILE__); |
|
21 | +define('LSX_SEARCH_URL', plugin_dir_url(__FILE__)); |
|
22 | +define('LSX_SEARCH_VER', '1.5.2'); |
|
23 | 23 | |
24 | 24 | /* ======================= Below is the Plugin Class init ========================= */ |
25 | 25 | |
26 | -require_once LSX_SEARCH_PATH . '/includes/template-tags.php'; |
|
27 | -require_once LSX_SEARCH_PATH . '/includes/functions.php'; |
|
28 | -require_once LSX_SEARCH_PATH . '/classes/class-lsx-search.php'; |
|
26 | +require_once LSX_SEARCH_PATH.'/includes/template-tags.php'; |
|
27 | +require_once LSX_SEARCH_PATH.'/includes/functions.php'; |
|
28 | +require_once LSX_SEARCH_PATH.'/classes/class-lsx-search.php'; |
@@ -10,186 +10,186 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class Settings_Theme { |
12 | 12 | |
13 | - /** |
|
14 | - * Holds class instance |
|
15 | - * |
|
16 | - * @since 1.0.0 |
|
17 | - * |
|
18 | - * @var object \lsx\search\classes\admin\Settings_Theme() |
|
19 | - */ |
|
20 | - protected static $instance = null; |
|
13 | + /** |
|
14 | + * Holds class instance |
|
15 | + * |
|
16 | + * @since 1.0.0 |
|
17 | + * |
|
18 | + * @var object \lsx\search\classes\admin\Settings_Theme() |
|
19 | + */ |
|
20 | + protected static $instance = null; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Will return true if this is the LSX Search settings page. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - public $is_options_page = false; |
|
22 | + /** |
|
23 | + * Will return true if this is the LSX Search settings page. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + public $is_options_page = false; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Holds the id and labels for the navigation. |
|
31 | - * |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - public $navigation = array(); |
|
29 | + /** |
|
30 | + * Holds the id and labels for the navigation. |
|
31 | + * |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + public $navigation = array(); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Contructor |
|
38 | - */ |
|
39 | - public function __construct() { |
|
40 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
41 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
42 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
43 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
44 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
45 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
46 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
47 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
48 | - } |
|
36 | + /** |
|
37 | + * Contructor |
|
38 | + */ |
|
39 | + public function __construct() { |
|
40 | + add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
41 | + add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
42 | + add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
43 | + add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
44 | + add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
45 | + add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
46 | + add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
47 | + add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Return an instance of this class. |
|
52 | - * |
|
53 | - * @since 1.0.0 |
|
54 | - * |
|
55 | - * @return object \lsx\search\classes\admin\Settings_Theme() A single instance of this class. |
|
56 | - */ |
|
57 | - public static function get_instance() { |
|
58 | - // If the single instance hasn't been set, set it now. |
|
59 | - if ( null == self::$instance ) { |
|
60 | - self::$instance = new self(); |
|
61 | - } |
|
62 | - return self::$instance; |
|
63 | - } |
|
50 | + /** |
|
51 | + * Return an instance of this class. |
|
52 | + * |
|
53 | + * @since 1.0.0 |
|
54 | + * |
|
55 | + * @return object \lsx\search\classes\admin\Settings_Theme() A single instance of this class. |
|
56 | + */ |
|
57 | + public static function get_instance() { |
|
58 | + // If the single instance hasn't been set, set it now. |
|
59 | + if ( null == self::$instance ) { |
|
60 | + self::$instance = new self(); |
|
61 | + } |
|
62 | + return self::$instance; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Disable CMB2 styles on front end forms. |
|
67 | - * |
|
68 | - * @return bool $enabled Whether to enable (enqueue) styles. |
|
69 | - */ |
|
70 | - public function disable_cmb2_styles( $enabled ) { |
|
71 | - if ( is_admin() ) { |
|
72 | - $current_screen = get_current_screen(); |
|
73 | - if ( is_object( $current_screen ) && 'settings_page_lsx-search-settings' === $current_screen->id ) { |
|
74 | - $enabled = false; |
|
75 | - } |
|
76 | - } |
|
77 | - return $enabled; |
|
78 | - } |
|
65 | + /** |
|
66 | + * Disable CMB2 styles on front end forms. |
|
67 | + * |
|
68 | + * @return bool $enabled Whether to enable (enqueue) styles. |
|
69 | + */ |
|
70 | + public function disable_cmb2_styles( $enabled ) { |
|
71 | + if ( is_admin() ) { |
|
72 | + $current_screen = get_current_screen(); |
|
73 | + if ( is_object( $current_screen ) && 'settings_page_lsx-search-settings' === $current_screen->id ) { |
|
74 | + $enabled = false; |
|
75 | + } |
|
76 | + } |
|
77 | + return $enabled; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Generates the tabbed navigation for the settings page. |
|
82 | - * |
|
83 | - * @param string $cmb_id |
|
84 | - * @param string $object_id |
|
85 | - * @param string $object_type |
|
86 | - * @param object $cmb2_obj |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
90 | - if ( 'lsx_search_settings' === $cmb_id && 'lsx-search-settings' === $object_id && 'options-page' === $object_type ) { |
|
91 | - $this->navigation = array(); |
|
92 | - $this->is_options_page = true; |
|
93 | - if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
94 | - foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
95 | - if ( 'title' === $field['type'] ) { |
|
96 | - $this->navigation[ $field_index ] = $field['name']; |
|
97 | - } |
|
98 | - } |
|
99 | - } |
|
100 | - $this->output_navigation(); |
|
101 | - } |
|
102 | - } |
|
80 | + /** |
|
81 | + * Generates the tabbed navigation for the settings page. |
|
82 | + * |
|
83 | + * @param string $cmb_id |
|
84 | + * @param string $object_id |
|
85 | + * @param string $object_type |
|
86 | + * @param object $cmb2_obj |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
90 | + if ( 'lsx_search_settings' === $cmb_id && 'lsx-search-settings' === $object_id && 'options-page' === $object_type ) { |
|
91 | + $this->navigation = array(); |
|
92 | + $this->is_options_page = true; |
|
93 | + if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
94 | + foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
95 | + if ( 'title' === $field['type'] ) { |
|
96 | + $this->navigation[ $field_index ] = $field['name']; |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | + $this->output_navigation(); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Outputs the WP style navigation for the Settings page. |
|
106 | - * |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function output_navigation() { |
|
110 | - if ( ! empty( $this->navigation ) ) { |
|
111 | - ?> |
|
104 | + /** |
|
105 | + * Outputs the WP style navigation for the Settings page. |
|
106 | + * |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function output_navigation() { |
|
110 | + if ( ! empty( $this->navigation ) ) { |
|
111 | + ?> |
|
112 | 112 | <div class="wp-filter hide-if-no-js"> |
113 | 113 | <ul class="filter-links"> |
114 | 114 | <?php |
115 | - $first_tab = true; |
|
116 | - $total = count( $this->navigation ); |
|
117 | - $count = 0; |
|
118 | - $separator = ' |'; |
|
119 | - $selected_tab = ''; |
|
120 | - if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
121 | - $selected_tab = sanitize_text_field( $_GET['cmb_tab'] ); |
|
122 | - $selected_tab = 'settings_' . $selected_tab; |
|
123 | - } |
|
124 | - foreach ( $this->navigation as $key => $label ) { |
|
125 | - $count++; |
|
126 | - $current_css = ''; |
|
127 | - if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
128 | - $first_tab = false; |
|
129 | - $current_css = 'current'; |
|
130 | - } |
|
131 | - if ( $count === $total ) { |
|
132 | - $separator = ''; |
|
133 | - } |
|
134 | - ?> |
|
115 | + $first_tab = true; |
|
116 | + $total = count( $this->navigation ); |
|
117 | + $count = 0; |
|
118 | + $separator = ' |'; |
|
119 | + $selected_tab = ''; |
|
120 | + if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
121 | + $selected_tab = sanitize_text_field( $_GET['cmb_tab'] ); |
|
122 | + $selected_tab = 'settings_' . $selected_tab; |
|
123 | + } |
|
124 | + foreach ( $this->navigation as $key => $label ) { |
|
125 | + $count++; |
|
126 | + $current_css = ''; |
|
127 | + if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
128 | + $first_tab = false; |
|
129 | + $current_css = 'current'; |
|
130 | + } |
|
131 | + if ( $count === $total ) { |
|
132 | + $separator = ''; |
|
133 | + } |
|
134 | + ?> |
|
135 | 135 | <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li> |
136 | 136 | <?php |
137 | - } |
|
138 | - ?> |
|
137 | + } |
|
138 | + ?> |
|
139 | 139 | </ul> |
140 | 140 | </div> |
141 | 141 | <?php |
142 | - } |
|
143 | - } |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Outputs the opening tab div. |
|
147 | - * |
|
148 | - * @param object $field CMB2_Field(); |
|
149 | - * @return void |
|
150 | - */ |
|
151 | - public function output_tab_open_div( $field ) { |
|
152 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
153 | - ?> |
|
145 | + /** |
|
146 | + * Outputs the opening tab div. |
|
147 | + * |
|
148 | + * @param object $field CMB2_Field(); |
|
149 | + * @return void |
|
150 | + */ |
|
151 | + public function output_tab_open_div( $field ) { |
|
152 | + if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
153 | + ?> |
|
154 | 154 | <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden"> |
155 | 155 | <?php |
156 | - } |
|
157 | - } |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Outputs the opening closing div. |
|
161 | - * |
|
162 | - * @param object $field CMB2_Field(); |
|
163 | - * @return void |
|
164 | - */ |
|
165 | - public function output_tab_closing_div( $field ) { |
|
166 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
167 | - ?> |
|
159 | + /** |
|
160 | + * Outputs the opening closing div. |
|
161 | + * |
|
162 | + * @param object $field CMB2_Field(); |
|
163 | + * @return void |
|
164 | + */ |
|
165 | + public function output_tab_closing_div( $field ) { |
|
166 | + if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
167 | + ?> |
|
168 | 168 | </div> |
169 | 169 | <?php |
170 | - } |
|
171 | - } |
|
170 | + } |
|
171 | + } |
|
172 | 172 | |
173 | - public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
174 | - return; |
|
175 | - } |
|
173 | + public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
174 | + return; |
|
175 | + } |
|
176 | 176 | |
177 | - public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
178 | - return ''; |
|
179 | - } |
|
177 | + public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
178 | + return ''; |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * Outputs the Script for the tabbed navigation. |
|
183 | - * |
|
184 | - * @param string $cmb_id |
|
185 | - * @param string $object_id |
|
186 | - * @param string $object_type |
|
187 | - * @param object $cmb2_obj |
|
188 | - * @return void |
|
189 | - */ |
|
190 | - public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
191 | - if ( 'lsx_search_settings' === $cmb_id && 'lsx-search-settings' === $object_id && 'options-page' === $object_type ) { |
|
192 | - ?> |
|
181 | + /** |
|
182 | + * Outputs the Script for the tabbed navigation. |
|
183 | + * |
|
184 | + * @param string $cmb_id |
|
185 | + * @param string $object_id |
|
186 | + * @param string $object_type |
|
187 | + * @param object $cmb2_obj |
|
188 | + * @return void |
|
189 | + */ |
|
190 | + public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
191 | + if ( 'lsx_search_settings' === $cmb_id && 'lsx-search-settings' === $object_id && 'options-page' === $object_type ) { |
|
192 | + ?> |
|
193 | 193 | <script> |
194 | 194 | var LSX_SEARCH_CMB2 = Object.create( null ); |
195 | 195 | |
@@ -261,25 +261,25 @@ discard block |
||
261 | 261 | } )( jQuery, window, document ); |
262 | 262 | </script> |
263 | 263 | <?php |
264 | - } |
|
265 | - } |
|
264 | + } |
|
265 | + } |
|
266 | 266 | |
267 | - /** |
|
268 | - * This will add the tab selection to the url. |
|
269 | - * |
|
270 | - * @param string $url |
|
271 | - * @return void |
|
272 | - */ |
|
273 | - public function add_tab_argument( $url ) { |
|
274 | - if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
275 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
276 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
277 | - if ( 'single' !== $tab_selection ) { |
|
278 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
279 | - } else { |
|
280 | - $url = remove_query_arg( 'cmb_tab', $url ); |
|
281 | - } |
|
282 | - } |
|
283 | - return $url; |
|
284 | - } |
|
267 | + /** |
|
268 | + * This will add the tab selection to the url. |
|
269 | + * |
|
270 | + * @param string $url |
|
271 | + * @return void |
|
272 | + */ |
|
273 | + public function add_tab_argument( $url ) { |
|
274 | + if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
275 | + $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
276 | + $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
277 | + if ( 'single' !== $tab_selection ) { |
|
278 | + $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
279 | + } else { |
|
280 | + $url = remove_query_arg( 'cmb_tab', $url ); |
|
281 | + } |
|
282 | + } |
|
283 | + return $url; |
|
284 | + } |
|
285 | 285 | } |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * Contructor |
38 | 38 | */ |
39 | 39 | public function __construct() { |
40 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
41 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
42 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
43 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
44 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
45 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
46 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
47 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
40 | + add_filter('cmb2_enqueue_css', array($this, 'disable_cmb2_styles'), 1, 1); |
|
41 | + add_action('cmb2_before_form', array($this, 'generate_navigation'), 10, 4); |
|
42 | + add_action('cmb2_before_title_field_row', array($this, 'output_tab_open_div'), 10, 1); |
|
43 | + add_action('cmb2_after_tab_closing_field_row', array($this, 'output_tab_closing_div'), 10, 1); |
|
44 | + add_action('cmb2_render_tab_closing', array($this, 'cmb2_render_callback_for_tab_closing'), 10, 5); |
|
45 | + add_filter('cmb2_sanitize_tab_closing', array($this, 'cmb2_sanitize_tab_closing_callback'), 10, 2); |
|
46 | + add_action('cmb2_after_form', array($this, 'navigation_js'), 10, 4); |
|
47 | + add_filter('cmb2_options_page_redirect_url', array($this, 'add_tab_argument'), 10, 1); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public static function get_instance() { |
58 | 58 | // If the single instance hasn't been set, set it now. |
59 | - if ( null == self::$instance ) { |
|
59 | + if (null == self::$instance) { |
|
60 | 60 | self::$instance = new self(); |
61 | 61 | } |
62 | 62 | return self::$instance; |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return bool $enabled Whether to enable (enqueue) styles. |
69 | 69 | */ |
70 | - public function disable_cmb2_styles( $enabled ) { |
|
71 | - if ( is_admin() ) { |
|
70 | + public function disable_cmb2_styles($enabled) { |
|
71 | + if (is_admin()) { |
|
72 | 72 | $current_screen = get_current_screen(); |
73 | - if ( is_object( $current_screen ) && 'settings_page_lsx-search-settings' === $current_screen->id ) { |
|
73 | + if (is_object($current_screen) && 'settings_page_lsx-search-settings' === $current_screen->id) { |
|
74 | 74 | $enabled = false; |
75 | 75 | } |
76 | 76 | } |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | * @param object $cmb2_obj |
87 | 87 | * @return void |
88 | 88 | */ |
89 | - public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
90 | - if ( 'lsx_search_settings' === $cmb_id && 'lsx-search-settings' === $object_id && 'options-page' === $object_type ) { |
|
89 | + public function generate_navigation($cmb_id, $object_id, $object_type, $cmb2_obj) { |
|
90 | + if ('lsx_search_settings' === $cmb_id && 'lsx-search-settings' === $object_id && 'options-page' === $object_type) { |
|
91 | 91 | $this->navigation = array(); |
92 | 92 | $this->is_options_page = true; |
93 | - if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
94 | - foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
95 | - if ( 'title' === $field['type'] ) { |
|
96 | - $this->navigation[ $field_index ] = $field['name']; |
|
93 | + if (isset($cmb2_obj->meta_box['fields']) && !empty($cmb2_obj->meta_box['fields'])) { |
|
94 | + foreach ($cmb2_obj->meta_box['fields'] as $field_index => $field) { |
|
95 | + if ('title' === $field['type']) { |
|
96 | + $this->navigation[$field_index] = $field['name']; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -107,32 +107,32 @@ discard block |
||
107 | 107 | * @return void |
108 | 108 | */ |
109 | 109 | public function output_navigation() { |
110 | - if ( ! empty( $this->navigation ) ) { |
|
110 | + if (!empty($this->navigation)) { |
|
111 | 111 | ?> |
112 | 112 | <div class="wp-filter hide-if-no-js"> |
113 | 113 | <ul class="filter-links"> |
114 | 114 | <?php |
115 | 115 | $first_tab = true; |
116 | - $total = count( $this->navigation ); |
|
116 | + $total = count($this->navigation); |
|
117 | 117 | $count = 0; |
118 | 118 | $separator = ' |'; |
119 | 119 | $selected_tab = ''; |
120 | - if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
121 | - $selected_tab = sanitize_text_field( $_GET['cmb_tab'] ); |
|
122 | - $selected_tab = 'settings_' . $selected_tab; |
|
120 | + if (isset($_GET['cmb_tab']) && '' !== $_GET['cmb_tab']) { |
|
121 | + $selected_tab = sanitize_text_field($_GET['cmb_tab']); |
|
122 | + $selected_tab = 'settings_'.$selected_tab; |
|
123 | 123 | } |
124 | - foreach ( $this->navigation as $key => $label ) { |
|
124 | + foreach ($this->navigation as $key => $label) { |
|
125 | 125 | $count++; |
126 | 126 | $current_css = ''; |
127 | - if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
127 | + if ((true === $first_tab && '' === $selected_tab) || $key === $selected_tab) { |
|
128 | 128 | $first_tab = false; |
129 | 129 | $current_css = 'current'; |
130 | 130 | } |
131 | - if ( $count === $total ) { |
|
131 | + if ($count === $total) { |
|
132 | 132 | $separator = ''; |
133 | 133 | } |
134 | 134 | ?> |
135 | - <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li> |
|
135 | + <li><a href="#" class="<?php echo esc_attr($current_css); ?>" data-sort="<?php echo esc_attr($key); ?>_tab"><?php echo esc_attr($label); ?></a><?php echo esc_attr($separator); ?></li> |
|
136 | 136 | <?php |
137 | 137 | } |
138 | 138 | ?> |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | * @param object $field CMB2_Field(); |
149 | 149 | * @return void |
150 | 150 | */ |
151 | - public function output_tab_open_div( $field ) { |
|
152 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
151 | + public function output_tab_open_div($field) { |
|
152 | + if (true === $this->is_options_page && isset($field->args['type']) && 'title' === $field->args['type']) { |
|
153 | 153 | ?> |
154 | - <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden"> |
|
154 | + <div id="<?php echo esc_attr($field->args['id']); ?>_tab" class="tab tab-nav hidden"> |
|
155 | 155 | <?php |
156 | 156 | } |
157 | 157 | } |
@@ -162,19 +162,19 @@ discard block |
||
162 | 162 | * @param object $field CMB2_Field(); |
163 | 163 | * @return void |
164 | 164 | */ |
165 | - public function output_tab_closing_div( $field ) { |
|
166 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
165 | + public function output_tab_closing_div($field) { |
|
166 | + if (true === $this->is_options_page && isset($field->args['type']) && 'tab_closing' === $field->args['type']) { |
|
167 | 167 | ?> |
168 | 168 | </div> |
169 | 169 | <?php |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
173 | + public function cmb2_render_callback_for_tab_closing($field, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
174 | 174 | return; |
175 | 175 | } |
176 | 176 | |
177 | - public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
177 | + public function cmb2_sanitize_tab_closing_callback($override_value, $value) { |
|
178 | 178 | return ''; |
179 | 179 | } |
180 | 180 | |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * @param object $cmb2_obj |
188 | 188 | * @return void |
189 | 189 | */ |
190 | - public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
191 | - if ( 'lsx_search_settings' === $cmb_id && 'lsx-search-settings' === $object_id && 'options-page' === $object_type ) { |
|
190 | + public function navigation_js($cmb_id, $object_id, $object_type, $cmb2_obj) { |
|
191 | + if ('lsx_search_settings' === $cmb_id && 'lsx-search-settings' === $object_id && 'options-page' === $object_type) { |
|
192 | 192 | ?> |
193 | 193 | <script> |
194 | 194 | var LSX_SEARCH_CMB2 = Object.create( null ); |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | * @param string $url |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - public function add_tab_argument( $url ) { |
|
274 | - if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
275 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
276 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
277 | - if ( 'single' !== $tab_selection ) { |
|
278 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
273 | + public function add_tab_argument($url) { |
|
274 | + if (isset($_POST['cmb_tab']) && '' !== $_POST['cmb_tab']) { // @codingStandardsIgnoreLine |
|
275 | + $tab_selection = sanitize_text_field($_POST['cmb_tab']); // @codingStandardsIgnoreLine |
|
276 | + $tab_selection = str_replace(array('settings_', '_tab'), '', $tab_selection); // @codingStandardsIgnoreLine |
|
277 | + if ('single' !== $tab_selection) { |
|
278 | + $url = add_query_arg('cmb_tab', $tab_selection, $url); |
|
279 | 279 | } else { |
280 | - $url = remove_query_arg( 'cmb_tab', $url ); |
|
280 | + $url = remove_query_arg('cmb_tab', $url); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | return $url; |
@@ -6,76 +6,76 @@ discard block |
||
6 | 6 | */ |
7 | 7 | class LSX_Search { |
8 | 8 | |
9 | - /** |
|
10 | - * Holds class instance |
|
11 | - * |
|
12 | - * @since 1.0.0 |
|
13 | - * |
|
14 | - * @var object LSX_Search() |
|
15 | - */ |
|
16 | - protected static $instance = null; |
|
9 | + /** |
|
10 | + * Holds class instance |
|
11 | + * |
|
12 | + * @since 1.0.0 |
|
13 | + * |
|
14 | + * @var object LSX_Search() |
|
15 | + */ |
|
16 | + protected static $instance = null; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @var LSX_Search_Admin() |
|
20 | - */ |
|
21 | - public $admin; |
|
18 | + /** |
|
19 | + * @var LSX_Search_Admin() |
|
20 | + */ |
|
21 | + public $admin; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var LSX_Search_Frontend() |
|
25 | - */ |
|
26 | - public $frontend; |
|
23 | + /** |
|
24 | + * @var LSX_Search_Frontend() |
|
25 | + */ |
|
26 | + public $frontend; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var LSX_Search_FacetWP() |
|
30 | - */ |
|
31 | - public $facetwp; |
|
28 | + /** |
|
29 | + * @var LSX_Search_FacetWP() |
|
30 | + */ |
|
31 | + public $facetwp; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var LSX_Search_Shortcode() |
|
35 | - */ |
|
36 | - public $shortcode; |
|
33 | + /** |
|
34 | + * @var LSX_Search_Shortcode() |
|
35 | + */ |
|
36 | + public $shortcode; |
|
37 | 37 | |
38 | - /** |
|
39 | - * LSX_Search constructor |
|
40 | - */ |
|
41 | - public function __construct() { |
|
42 | - $this->load_vendors(); |
|
38 | + /** |
|
39 | + * LSX_Search constructor |
|
40 | + */ |
|
41 | + public function __construct() { |
|
42 | + $this->load_vendors(); |
|
43 | 43 | |
44 | - require_once LSX_SEARCH_PATH . '/classes/class-admin.php'; |
|
45 | - require_once LSX_SEARCH_PATH . '/classes/class-frontend.php'; |
|
46 | - require_once LSX_SEARCH_PATH . '/classes/class-lsx-search-facetwp.php'; |
|
47 | - require_once LSX_SEARCH_PATH . '/classes/class-lsx-search-shortcode.php'; |
|
44 | + require_once LSX_SEARCH_PATH . '/classes/class-admin.php'; |
|
45 | + require_once LSX_SEARCH_PATH . '/classes/class-frontend.php'; |
|
46 | + require_once LSX_SEARCH_PATH . '/classes/class-lsx-search-facetwp.php'; |
|
47 | + require_once LSX_SEARCH_PATH . '/classes/class-lsx-search-shortcode.php'; |
|
48 | 48 | |
49 | - $this->admin = \lsx\search\classes\Admin::get_instance(); |
|
50 | - $this->frontend = \lsx\search\classes\Frontend::get_instance(); |
|
51 | - $this->facetwp = new LSX_Search_FacetWP(); |
|
52 | - $this->shortcode = new LSX_Search_Shortcode(); |
|
53 | - } |
|
49 | + $this->admin = \lsx\search\classes\Admin::get_instance(); |
|
50 | + $this->frontend = \lsx\search\classes\Frontend::get_instance(); |
|
51 | + $this->facetwp = new LSX_Search_FacetWP(); |
|
52 | + $this->shortcode = new LSX_Search_Shortcode(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Return an instance of this class. |
|
57 | - * |
|
58 | - * @since 1.0.0 |
|
59 | - * |
|
60 | - * @return object LSX_Search() A single instance of this class. |
|
61 | - */ |
|
62 | - public static function get_instance() { |
|
63 | - // If the single instance hasn't been set, set it now. |
|
64 | - if ( null === self::$instance ) { |
|
65 | - self::$instance = new self(); |
|
66 | - } |
|
67 | - return self::$instance; |
|
68 | - } |
|
55 | + /** |
|
56 | + * Return an instance of this class. |
|
57 | + * |
|
58 | + * @since 1.0.0 |
|
59 | + * |
|
60 | + * @return object LSX_Search() A single instance of this class. |
|
61 | + */ |
|
62 | + public static function get_instance() { |
|
63 | + // If the single instance hasn't been set, set it now. |
|
64 | + if ( null === self::$instance ) { |
|
65 | + self::$instance = new self(); |
|
66 | + } |
|
67 | + return self::$instance; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Loads the plugin functions. |
|
72 | - */ |
|
73 | - private function load_vendors() { |
|
74 | - // Configure custom fields. |
|
75 | - if ( ! class_exists( 'CMB2' ) ) { |
|
76 | - require_once LSX_SEARCH_PATH . 'vendor/CMB2/init.php'; |
|
77 | - } |
|
78 | - } |
|
70 | + /** |
|
71 | + * Loads the plugin functions. |
|
72 | + */ |
|
73 | + private function load_vendors() { |
|
74 | + // Configure custom fields. |
|
75 | + if ( ! class_exists( 'CMB2' ) ) { |
|
76 | + require_once LSX_SEARCH_PATH . 'vendor/CMB2/init.php'; |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @return object LSX_Search(); |
85 | 85 | */ |
86 | 86 | function lsx_search() { |
87 | - global $lsx_search; |
|
88 | - $lsx_search = LSX_Search::get_instance(); |
|
89 | - return $lsx_search; |
|
87 | + global $lsx_search; |
|
88 | + $lsx_search = LSX_Search::get_instance(); |
|
89 | + return $lsx_search; |
|
90 | 90 | } |
91 | 91 | lsx_search(); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | public function __construct() { |
42 | 42 | $this->load_vendors(); |
43 | 43 | |
44 | - require_once LSX_SEARCH_PATH . '/classes/class-admin.php'; |
|
45 | - require_once LSX_SEARCH_PATH . '/classes/class-frontend.php'; |
|
46 | - require_once LSX_SEARCH_PATH . '/classes/class-lsx-search-facetwp.php'; |
|
47 | - require_once LSX_SEARCH_PATH . '/classes/class-lsx-search-shortcode.php'; |
|
44 | + require_once LSX_SEARCH_PATH.'/classes/class-admin.php'; |
|
45 | + require_once LSX_SEARCH_PATH.'/classes/class-frontend.php'; |
|
46 | + require_once LSX_SEARCH_PATH.'/classes/class-lsx-search-facetwp.php'; |
|
47 | + require_once LSX_SEARCH_PATH.'/classes/class-lsx-search-shortcode.php'; |
|
48 | 48 | |
49 | 49 | $this->admin = \lsx\search\classes\Admin::get_instance(); |
50 | 50 | $this->frontend = \lsx\search\classes\Frontend::get_instance(); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public static function get_instance() { |
63 | 63 | // If the single instance hasn't been set, set it now. |
64 | - if ( null === self::$instance ) { |
|
64 | + if (null === self::$instance) { |
|
65 | 65 | self::$instance = new self(); |
66 | 66 | } |
67 | 67 | return self::$instance; |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | */ |
73 | 73 | private function load_vendors() { |
74 | 74 | // Configure custom fields. |
75 | - if ( ! class_exists( 'CMB2' ) ) { |
|
76 | - require_once LSX_SEARCH_PATH . 'vendor/CMB2/init.php'; |
|
75 | + if (!class_exists('CMB2')) { |
|
76 | + require_once LSX_SEARCH_PATH.'vendor/CMB2/init.php'; |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | } |
@@ -7,61 +7,61 @@ discard block |
||
7 | 7 | |
8 | 8 | class Hierarchy { |
9 | 9 | |
10 | - /** |
|
11 | - * Holds class instance |
|
12 | - * |
|
13 | - * @since 1.0.0 |
|
14 | - * |
|
15 | - * @var object \lsx\search\classes\facetwp\Hierarchy() |
|
16 | - */ |
|
17 | - protected static $instance = null; |
|
18 | - |
|
19 | - /** |
|
20 | - * Constructor |
|
21 | - */ |
|
22 | - public function __construct() { |
|
23 | - add_filter( 'facetwp_facet_html', array( $this, 'checkbox_facet_html' ), 100, 2 ); |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * Return an instance of this class. |
|
28 | - * |
|
29 | - * @since 1.0.0 |
|
30 | - * |
|
31 | - * @return object \lsx\search\classes\facetwp\Hierarchy() A single instance of this class. |
|
32 | - */ |
|
33 | - public static function get_instance() { |
|
34 | - // If the single instance hasn't been set, set it now. |
|
35 | - if ( null === self::$instance ) { |
|
36 | - self::$instance = new self(); |
|
37 | - } |
|
38 | - return self::$instance; |
|
39 | - } |
|
40 | - |
|
41 | - public function checkbox_facet_html( $output, $params ) { |
|
42 | - if ( 'checkboxes' === $params['facet']['type'] && 'yes' === $params['facet']['hierarchical'] ) { |
|
43 | - $output = $this->render_hierarchy( $params ); |
|
44 | - } |
|
45 | - return $output; |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Generate the facet HTML (hierarchical taxonomies) |
|
50 | - */ |
|
51 | - function render_hierarchy( $params ) { |
|
52 | - |
|
53 | - $output = ''; |
|
54 | - $facet = $params['facet']; |
|
55 | - $selected_values = (array) $params['selected_values']; |
|
56 | - $values = FWP()->helper->sort_taxonomy_values( $params['values'], $facet['orderby'] ); |
|
57 | - |
|
58 | - $init_depth = -1; |
|
59 | - $last_depth = -1; |
|
60 | - |
|
61 | - foreach ( $values as $result ) { |
|
62 | - $depth = (int) $result['depth']; |
|
63 | - |
|
64 | - /*if ( -1 == $last_depth ) { |
|
10 | + /** |
|
11 | + * Holds class instance |
|
12 | + * |
|
13 | + * @since 1.0.0 |
|
14 | + * |
|
15 | + * @var object \lsx\search\classes\facetwp\Hierarchy() |
|
16 | + */ |
|
17 | + protected static $instance = null; |
|
18 | + |
|
19 | + /** |
|
20 | + * Constructor |
|
21 | + */ |
|
22 | + public function __construct() { |
|
23 | + add_filter( 'facetwp_facet_html', array( $this, 'checkbox_facet_html' ), 100, 2 ); |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * Return an instance of this class. |
|
28 | + * |
|
29 | + * @since 1.0.0 |
|
30 | + * |
|
31 | + * @return object \lsx\search\classes\facetwp\Hierarchy() A single instance of this class. |
|
32 | + */ |
|
33 | + public static function get_instance() { |
|
34 | + // If the single instance hasn't been set, set it now. |
|
35 | + if ( null === self::$instance ) { |
|
36 | + self::$instance = new self(); |
|
37 | + } |
|
38 | + return self::$instance; |
|
39 | + } |
|
40 | + |
|
41 | + public function checkbox_facet_html( $output, $params ) { |
|
42 | + if ( 'checkboxes' === $params['facet']['type'] && 'yes' === $params['facet']['hierarchical'] ) { |
|
43 | + $output = $this->render_hierarchy( $params ); |
|
44 | + } |
|
45 | + return $output; |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Generate the facet HTML (hierarchical taxonomies) |
|
50 | + */ |
|
51 | + function render_hierarchy( $params ) { |
|
52 | + |
|
53 | + $output = ''; |
|
54 | + $facet = $params['facet']; |
|
55 | + $selected_values = (array) $params['selected_values']; |
|
56 | + $values = FWP()->helper->sort_taxonomy_values( $params['values'], $facet['orderby'] ); |
|
57 | + |
|
58 | + $init_depth = -1; |
|
59 | + $last_depth = -1; |
|
60 | + |
|
61 | + foreach ( $values as $result ) { |
|
62 | + $depth = (int) $result['depth']; |
|
63 | + |
|
64 | + /*if ( -1 == $last_depth ) { |
|
65 | 65 | $init_depth = $depth; |
66 | 66 | } |
67 | 67 | elseif ( $depth > $last_depth ) { |
@@ -73,23 +73,23 @@ discard block |
||
73 | 73 | } |
74 | 74 | }*/ |
75 | 75 | |
76 | - $selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : ''; |
|
77 | - $selected .= ( 0 == $result['counter'] && '' == $selected ) ? ' disabled' : ''; |
|
76 | + $selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : ''; |
|
77 | + $selected .= ( 0 == $result['counter'] && '' == $selected ) ? ' disabled' : ''; |
|
78 | 78 | |
79 | - $is_child = ( 0 == $result['parent_id'] && '0' == $result['parent_id'] ) ? ' is-child' : ''; |
|
80 | - $depth_css = ' depth-' . $result['depth']; |
|
79 | + $is_child = ( 0 == $result['parent_id'] && '0' == $result['parent_id'] ) ? ' is-child' : ''; |
|
80 | + $depth_css = ' depth-' . $result['depth']; |
|
81 | 81 | |
82 | - $output .= '<div class="facetwp-checkbox' . $selected . $is_child . $depth_css . '" data-parent-id="' . esc_attr( $result['parent_id'] ) . '" data-value="' . esc_attr( $result['facet_value'] ) . '">'; |
|
83 | - $output .= esc_html( $result['facet_display_value'] ) . ' <span class="facetwp-counter">(' . $result['counter'] . ')</span>'; |
|
84 | - $output .= '</div>'; |
|
82 | + $output .= '<div class="facetwp-checkbox' . $selected . $is_child . $depth_css . '" data-parent-id="' . esc_attr( $result['parent_id'] ) . '" data-value="' . esc_attr( $result['facet_value'] ) . '">'; |
|
83 | + $output .= esc_html( $result['facet_display_value'] ) . ' <span class="facetwp-counter">(' . $result['counter'] . ')</span>'; |
|
84 | + $output .= '</div>'; |
|
85 | 85 | |
86 | - $last_depth = $depth; |
|
87 | - } |
|
86 | + $last_depth = $depth; |
|
87 | + } |
|
88 | 88 | |
89 | - for ( $i = $last_depth; $i > $init_depth; $i-- ) { |
|
90 | - $output .= '</div>'; |
|
91 | - } |
|
89 | + for ( $i = $last_depth; $i > $init_depth; $i-- ) { |
|
90 | + $output .= '</div>'; |
|
91 | + } |
|
92 | 92 | |
93 | - return $output; |
|
94 | - } |
|
93 | + return $output; |
|
94 | + } |
|
95 | 95 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * Constructor |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | - add_filter( 'facetwp_facet_html', array( $this, 'checkbox_facet_html' ), 100, 2 ); |
|
23 | + add_filter('facetwp_facet_html', array($this, 'checkbox_facet_html'), 100, 2); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function get_instance() { |
34 | 34 | // If the single instance hasn't been set, set it now. |
35 | - if ( null === self::$instance ) { |
|
35 | + if (null === self::$instance) { |
|
36 | 36 | self::$instance = new self(); |
37 | 37 | } |
38 | 38 | return self::$instance; |
39 | 39 | } |
40 | 40 | |
41 | - public function checkbox_facet_html( $output, $params ) { |
|
42 | - if ( 'checkboxes' === $params['facet']['type'] && 'yes' === $params['facet']['hierarchical'] ) { |
|
43 | - $output = $this->render_hierarchy( $params ); |
|
41 | + public function checkbox_facet_html($output, $params) { |
|
42 | + if ('checkboxes' === $params['facet']['type'] && 'yes' === $params['facet']['hierarchical']) { |
|
43 | + $output = $this->render_hierarchy($params); |
|
44 | 44 | } |
45 | 45 | return $output; |
46 | 46 | } |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * Generate the facet HTML (hierarchical taxonomies) |
50 | 50 | */ |
51 | - function render_hierarchy( $params ) { |
|
51 | + function render_hierarchy($params) { |
|
52 | 52 | |
53 | 53 | $output = ''; |
54 | 54 | $facet = $params['facet']; |
55 | 55 | $selected_values = (array) $params['selected_values']; |
56 | - $values = FWP()->helper->sort_taxonomy_values( $params['values'], $facet['orderby'] ); |
|
56 | + $values = FWP()->helper->sort_taxonomy_values($params['values'], $facet['orderby']); |
|
57 | 57 | |
58 | 58 | $init_depth = -1; |
59 | 59 | $last_depth = -1; |
60 | 60 | |
61 | - foreach ( $values as $result ) { |
|
61 | + foreach ($values as $result) { |
|
62 | 62 | $depth = (int) $result['depth']; |
63 | 63 | |
64 | 64 | /*if ( -1 == $last_depth ) { |
@@ -73,20 +73,20 @@ discard block |
||
73 | 73 | } |
74 | 74 | }*/ |
75 | 75 | |
76 | - $selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : ''; |
|
77 | - $selected .= ( 0 == $result['counter'] && '' == $selected ) ? ' disabled' : ''; |
|
76 | + $selected = in_array($result['facet_value'], $selected_values) ? ' checked' : ''; |
|
77 | + $selected .= (0 == $result['counter'] && '' == $selected) ? ' disabled' : ''; |
|
78 | 78 | |
79 | - $is_child = ( 0 == $result['parent_id'] && '0' == $result['parent_id'] ) ? ' is-child' : ''; |
|
80 | - $depth_css = ' depth-' . $result['depth']; |
|
79 | + $is_child = (0 == $result['parent_id'] && '0' == $result['parent_id']) ? ' is-child' : ''; |
|
80 | + $depth_css = ' depth-'.$result['depth']; |
|
81 | 81 | |
82 | - $output .= '<div class="facetwp-checkbox' . $selected . $is_child . $depth_css . '" data-parent-id="' . esc_attr( $result['parent_id'] ) . '" data-value="' . esc_attr( $result['facet_value'] ) . '">'; |
|
83 | - $output .= esc_html( $result['facet_display_value'] ) . ' <span class="facetwp-counter">(' . $result['counter'] . ')</span>'; |
|
82 | + $output .= '<div class="facetwp-checkbox'.$selected.$is_child.$depth_css.'" data-parent-id="'.esc_attr($result['parent_id']).'" data-value="'.esc_attr($result['facet_value']).'">'; |
|
83 | + $output .= esc_html($result['facet_display_value']).' <span class="facetwp-counter">('.$result['counter'].')</span>'; |
|
84 | 84 | $output .= '</div>'; |
85 | 85 | |
86 | 86 | $last_depth = $depth; |
87 | 87 | } |
88 | 88 | |
89 | - for ( $i = $last_depth; $i > $init_depth; $i-- ) { |
|
89 | + for ($i = $last_depth; $i > $init_depth; $i--) { |
|
90 | 90 | $output .= '</div>'; |
91 | 91 | } |
92 | 92 |
@@ -7,381 +7,381 @@ |
||
7 | 7 | |
8 | 8 | class Post_Connections { |
9 | 9 | |
10 | - /** |
|
11 | - * Holds class instance |
|
12 | - * |
|
13 | - * @since 1.0.0 |
|
14 | - * |
|
15 | - * @var object \lsx\search\classes\facetwp\Post_Connections() |
|
16 | - */ |
|
17 | - protected static $instance = null; |
|
18 | - |
|
19 | - /** |
|
20 | - * Holds the plugin options. |
|
21 | - * |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - public $options = array(); |
|
25 | - |
|
26 | - /** |
|
27 | - * Constructor |
|
28 | - */ |
|
29 | - public function __construct() { |
|
30 | - $this->get_cmb2_options(); |
|
31 | - add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 10, 2 ); |
|
32 | - add_filter( 'facetwp_index_row', array( $this, 'facetwp_index_row' ), 10, 2 ); |
|
33 | - add_filter( 'facetwp_facet_html', array( $this, 'destination_facet_html' ), 10, 2 ); |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * Gets the cmb2 options. |
|
38 | - * |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - private function get_cmb2_options() { |
|
42 | - $cmb2_options = get_option( 'lsx-search-settings' ); |
|
43 | - if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
44 | - $this->options['display'] = $cmb2_options; |
|
45 | - foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
46 | - if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
47 | - $new_values = array(); |
|
48 | - foreach ( $option_value as $empty_key => $key_value ) { |
|
49 | - $new_values[ $key_value ] = 'on'; |
|
50 | - } |
|
51 | - $this->options['display'][ $option_key ] = $new_values; |
|
52 | - } |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - /*print_r('<pre>'); |
|
10 | + /** |
|
11 | + * Holds class instance |
|
12 | + * |
|
13 | + * @since 1.0.0 |
|
14 | + * |
|
15 | + * @var object \lsx\search\classes\facetwp\Post_Connections() |
|
16 | + */ |
|
17 | + protected static $instance = null; |
|
18 | + |
|
19 | + /** |
|
20 | + * Holds the plugin options. |
|
21 | + * |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + public $options = array(); |
|
25 | + |
|
26 | + /** |
|
27 | + * Constructor |
|
28 | + */ |
|
29 | + public function __construct() { |
|
30 | + $this->get_cmb2_options(); |
|
31 | + add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 10, 2 ); |
|
32 | + add_filter( 'facetwp_index_row', array( $this, 'facetwp_index_row' ), 10, 2 ); |
|
33 | + add_filter( 'facetwp_facet_html', array( $this, 'destination_facet_html' ), 10, 2 ); |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * Gets the cmb2 options. |
|
38 | + * |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + private function get_cmb2_options() { |
|
42 | + $cmb2_options = get_option( 'lsx-search-settings' ); |
|
43 | + if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
44 | + $this->options['display'] = $cmb2_options; |
|
45 | + foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
46 | + if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
47 | + $new_values = array(); |
|
48 | + foreach ( $option_value as $empty_key => $key_value ) { |
|
49 | + $new_values[ $key_value ] = 'on'; |
|
50 | + } |
|
51 | + $this->options['display'][ $option_key ] = $new_values; |
|
52 | + } |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + /*print_r('<pre>'); |
|
57 | 57 | print_r($this->options); |
58 | 58 | print_r('</pre>'); |
59 | 59 | die();*/ |
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Return an instance of this class. |
|
64 | - * |
|
65 | - * @since 1.0.0 |
|
66 | - * |
|
67 | - * @return object \lsx\search\classes\facetwp\Post_Connections() A single instance of this class. |
|
68 | - */ |
|
69 | - public static function get_instance() { |
|
70 | - // If the single instance hasn't been set, set it now. |
|
71 | - if ( null === self::$instance ) { |
|
72 | - self::$instance = new self(); |
|
73 | - } |
|
74 | - return self::$instance; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Alter the rows and include extra facets rows for the continents |
|
79 | - */ |
|
80 | - public function facetwp_index_row_data( $rows, $params ) { |
|
81 | - switch ( $params['facet']['source'] ) { |
|
82 | - case 'cf/destination_to_tour': |
|
83 | - case 'cf/destination_to_accommodation': |
|
84 | - $countries = array(); |
|
85 | - |
|
86 | - foreach ( $rows as $r_index => $row ) { |
|
87 | - $parent = wp_get_post_parent_id( $row['facet_value'] ); |
|
88 | - $rows[ $r_index ]['parent_id'] = $parent; |
|
89 | - |
|
90 | - if ( 0 === $parent || '0' === $parent ) { |
|
91 | - if ( ! isset( $countries[ $r_index ] ) ) { |
|
92 | - $countries[ $r_index ] = $row['facet_value']; |
|
93 | - } |
|
94 | - |
|
95 | - if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
96 | - $rows[ $r_index ]['depth'] = 1; |
|
97 | - } else { |
|
98 | - $rows[ $r_index ]['depth'] = 0; |
|
99 | - } |
|
100 | - } else { |
|
101 | - if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
102 | - $rows[ $r_index ]['depth'] = 2; |
|
103 | - } else { |
|
104 | - $rows[ $r_index ]['depth'] = 1; |
|
105 | - } |
|
106 | - } |
|
107 | - } |
|
108 | - if ( ! empty( $this->options['display']['enable_search_continent_filter'] ) ) { |
|
109 | - if ( ! empty( $countries ) ) { |
|
110 | - foreach ( $countries as $row_index => $country ) { |
|
111 | - $continents = wp_get_object_terms( $country, 'continent' ); |
|
112 | - $continent_id = 0; |
|
113 | - |
|
114 | - if ( ! is_wp_error( $continents ) ) { |
|
115 | - $new_row = $params['defaults']; |
|
116 | - if ( ! is_array( $continents ) ) { |
|
117 | - $continents = array( $continents ); |
|
118 | - } |
|
119 | - |
|
120 | - foreach ( $continents as $continent ) { |
|
121 | - $new_row['facet_value'] = $continent->slug; |
|
122 | - $new_row['facet_display_value'] = $continent->name; |
|
123 | - $continent_id = $continent->term_id; |
|
124 | - $new_row['depth'] = 0; |
|
125 | - } |
|
126 | - $rows[] = $new_row; |
|
127 | - $rows[ $row_index ]['parent_id'] = $continent_id; |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
131 | - } |
|
132 | - |
|
133 | - break; |
|
134 | - |
|
135 | - default: |
|
136 | - break; |
|
137 | - } |
|
138 | - |
|
139 | - return $rows; |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Displays the destination specific settings |
|
144 | - */ |
|
145 | - public function facetwp_index_row( $params, $class ) { |
|
146 | - $custom_field = false; |
|
147 | - $meta_key = false; |
|
148 | - |
|
149 | - preg_match( '/cf\//', $class->facet['source'], $custom_field ); |
|
150 | - preg_match( '/_to_/', $class->facet['source'], $meta_key ); |
|
151 | - |
|
152 | - if ( ! empty( $custom_field ) && ! empty( $meta_key ) ) { |
|
153 | - |
|
154 | - if ( ( 'cf/destination_to_accommodation' === $class->facet['source'] || 'cf/destination_to_tour' === $class->facet['source'] ) && ! empty( $this->options['display']['engine_search_continent_filter'] ) && ( '0' === (string) $params['depth'] ) ) { |
|
155 | - $title = ''; |
|
156 | - } else { |
|
157 | - $title = get_the_title( $params['facet_value'] ); |
|
158 | - if ( '' !== $title ) { |
|
159 | - $params['facet_display_value'] = $title; |
|
160 | - } |
|
161 | - if ( '' === $title && ! empty( $meta_key ) ) { |
|
162 | - $params['facet_value'] = ''; |
|
163 | - } |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - // If its a price, save the value as a standard number. |
|
168 | - if ( 'cf/price' === $class->facet['source'] ) { |
|
169 | - $params['facet_value'] = preg_replace( '/[^0-9.]/', '', $params['facet_value'] ); |
|
170 | - $params['facet_value'] = ltrim( $params['facet_value'], '.' ); |
|
171 | - #$params['facet_value'] = number_format( (int) $params['facet_value'], 2 ); |
|
172 | - $params['facet_display_value'] = $params['facet_value']; |
|
173 | - } |
|
174 | - |
|
175 | - // If its a duration, save the value as a standard number. |
|
176 | - if ( 'cf/duration' === $class->facet['source'] ) { |
|
177 | - $params['facet_value'] = preg_replace( '/[^0-9 ]/', '', $params['facet_value'] ); |
|
178 | - $params['facet_value'] = trim( $params['facet_value'] ); |
|
179 | - $params['facet_value'] = explode( ' ', $params['facet_value'] ); |
|
180 | - $params['facet_value'] = $params['facet_value'][0]; |
|
181 | - #$params['facet_value'] = (int) $params['facet_value']; |
|
182 | - $params['facet_display_value'] = $params['facet_value']; |
|
183 | - } |
|
184 | - |
|
185 | - return $params; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Checks the facet source value and outputs the destination facet HTML if needed. |
|
190 | - * |
|
191 | - * @param string $output |
|
192 | - * @param array $params |
|
193 | - * @return string |
|
194 | - */ |
|
195 | - public function destination_facet_html( $output, $params ) { |
|
196 | - $possible_keys = array( |
|
197 | - 'cf/destination_to_accommodation', |
|
198 | - 'cf/destination_to_tour', |
|
199 | - 'cf/destination_to_special', |
|
200 | - 'cf/destination_to_activity', |
|
201 | - 'cf/destination_to_review', |
|
202 | - 'cf/destination_to_vehicle', |
|
203 | - ); |
|
204 | - if ( in_array( $params['facet']['source'], $possible_keys ) ) { |
|
205 | - $output = $this->destination_facet_render( $params ); |
|
206 | - } |
|
207 | - return $output; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Generate the facet HTML |
|
212 | - */ |
|
213 | - public function destination_facet_render( $params ) { |
|
214 | - $facet = $params['facet']; |
|
215 | - |
|
216 | - $output = ''; |
|
217 | - $values = (array) $params['values']; |
|
218 | - $selected_values = (array) $params['selected_values']; |
|
219 | - $soft_limit = empty( $facet['soft_limit'] ) ? 0 : (int) $facet['soft_limit']; |
|
220 | - $countries = array(); |
|
221 | - $continents = array(); |
|
222 | - |
|
223 | - $continent_terms = get_terms( |
|
224 | - array( |
|
225 | - 'taxonomy' => 'continent', |
|
226 | - ) |
|
227 | - ); |
|
228 | - |
|
229 | - if ( ! is_wp_error( $continent_terms ) ) { |
|
230 | - foreach ( $continent_terms as $continent ) { |
|
231 | - $continents[ $continent->term_id ] = $continent->slug; |
|
232 | - } |
|
233 | - } |
|
234 | - |
|
235 | - //Create a relationship of the facet value and the their depths |
|
236 | - $depths = array(); |
|
237 | - $parents = array(); |
|
238 | - foreach ( $values as $value ) { |
|
239 | - $depths[ $value['facet_value'] ] = (int) $value['depth']; |
|
240 | - $parents[ $value['facet_value'] ] = (int) $value['parent_id']; |
|
241 | - } |
|
242 | - |
|
243 | - //Determine the current depth and check if the selected values parents are in the selected array. |
|
244 | - $current_depth = 0; |
|
245 | - $additional_values = array(); |
|
246 | - if ( ! empty( $selected_values ) ) { |
|
247 | - foreach ( $selected_values as $selected ) { |
|
248 | - if ( $depths[ $selected ] > $current_depth ) { |
|
249 | - $current_depth = $depths[ $selected ]; |
|
250 | - } |
|
251 | - } |
|
252 | - $current_depth++; |
|
253 | - } |
|
254 | - |
|
255 | - if ( ! empty( $additional_values ) ) { |
|
256 | - $selected_values = array_merge( $selected_values, $additional_values ); |
|
257 | - } |
|
258 | - |
|
259 | - // This is where the items are sorted by their depth |
|
260 | - $sorted_values = array(); |
|
261 | - $stored = $values; |
|
262 | - |
|
263 | - //sort the options so |
|
264 | - foreach ( $values as $key => $result ) { |
|
265 | - if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
266 | - if ( in_array( $result['facet_value'], $continents ) ) { |
|
267 | - $sorted_values[] = $result; |
|
268 | - $destinations = $this->get_countries( $stored, $result['facet_value'], $continents, '1' ); |
|
269 | - |
|
270 | - if ( ! empty( $destinations ) ) { |
|
271 | - foreach ( $destinations as $destination ) { |
|
272 | - $sorted_values[] = $destination; |
|
273 | - } |
|
274 | - } |
|
275 | - } |
|
276 | - } else { |
|
277 | - if ( '0' === $result['depth'] || 0 === $result['depth'] ) { |
|
278 | - $sorted_values[] = $result; |
|
279 | - $destinations = $this->get_regions( $stored, $result['facet_value'], '1' ); |
|
280 | - |
|
281 | - if ( ! empty( $destinations ) ) { |
|
282 | - foreach ( $destinations as $destination ) { |
|
283 | - $sorted_values[] = $destination; |
|
284 | - } |
|
285 | - } |
|
286 | - } |
|
287 | - } |
|
288 | - } |
|
289 | - $values = $sorted_values; |
|
290 | - |
|
291 | - $continent_class = ''; |
|
292 | - $country_class = ''; |
|
293 | - |
|
294 | - // Run through each value and output the values. |
|
295 | - foreach ( $values as $key => $facet ) { |
|
296 | - $depth_type = ''; |
|
297 | - |
|
298 | - if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
299 | - switch ( $facet['depth'] ) { |
|
300 | - case '0': |
|
301 | - $depth_type = ''; |
|
302 | - $continent_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' continent-checked' : ''; |
|
303 | - break; |
|
304 | - |
|
305 | - case '1': |
|
306 | - $depth_type = 'country' . $continent_class; |
|
307 | - $country_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' country-checked' : ''; |
|
308 | - break; |
|
309 | - |
|
310 | - case '2': |
|
311 | - $depth_type = 'region' . $continent_class . $country_class; |
|
312 | - break; |
|
313 | - } |
|
314 | - } else { |
|
315 | - switch ( $facet['depth'] ) { |
|
316 | - case '0': |
|
317 | - $depth_type = 'country continent-checked'; |
|
318 | - $country_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' country-checked' : ''; |
|
319 | - break; |
|
320 | - |
|
321 | - case '1': |
|
322 | - $depth_type = 'region continent-checked' . $country_class; |
|
323 | - break; |
|
324 | - } |
|
325 | - } |
|
326 | - |
|
327 | - if ( $facet['depth'] <= $current_depth ) { |
|
328 | - $options[] = $this->format_single_facet( $key, $facet, $selected_values, $depth_type ); |
|
329 | - } |
|
330 | - } |
|
331 | - |
|
332 | - if ( ! empty( $options ) ) { |
|
333 | - $output = implode( '', $options ); |
|
334 | - } |
|
335 | - |
|
336 | - return $output; |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * Gets the direct countries from the array. |
|
341 | - */ |
|
342 | - public function get_countries( $values, $parent, $continents, $depth ) { |
|
343 | - $children = array(); |
|
344 | - $stored = $values; |
|
345 | - |
|
346 | - foreach ( $values as $value ) { |
|
347 | - if ( isset( $continents[ $value['parent_id'] ] ) && $continents[ $value['parent_id'] ] === $parent && $value['depth'] === $depth ) { |
|
348 | - $children[] = $value; |
|
349 | - |
|
350 | - $destinations = $this->get_regions( $stored, $value['facet_value'], '2' ); |
|
351 | - if ( ! empty( $destinations ) ) { |
|
352 | - foreach ( $destinations as $destination ) { |
|
353 | - $children[] = $destination; |
|
354 | - } |
|
355 | - } |
|
356 | - } |
|
357 | - } |
|
358 | - return $children; |
|
359 | - } |
|
360 | - |
|
361 | - /** |
|
362 | - * Gets the direct regions from the array. |
|
363 | - */ |
|
364 | - public function get_regions( $values, $parent, $depth ) { |
|
365 | - $children = array(); |
|
366 | - foreach ( $values as $value ) { |
|
367 | - if ( $value['parent_id'] === $parent && $value['depth'] === $depth ) { |
|
368 | - $children[] = $value; |
|
369 | - } |
|
370 | - } |
|
371 | - return $children; |
|
372 | - } |
|
373 | - |
|
374 | - public function format_single_facet( $key, $result, $selected_values, $region = '' ) { |
|
375 | - $temp_html = ''; |
|
376 | - |
|
377 | - $selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : ''; |
|
378 | - $selected .= ( 0 == $result['counter'] && '' == $selected ) ? ' disabled' : ''; |
|
379 | - $selected .= ' ' . $region; |
|
380 | - |
|
381 | - $temp_html .= '<div class="facetwp-checkbox' . $selected . '" data-value="' . $result['facet_value'] . '">'; |
|
382 | - $temp_html .= $result['facet_display_value'] . ' <span class="facetwp-counter">(' . $result['counter'] . ')</span>'; |
|
383 | - $temp_html .= '</div>'; |
|
384 | - |
|
385 | - return $temp_html; |
|
386 | - } |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Return an instance of this class. |
|
64 | + * |
|
65 | + * @since 1.0.0 |
|
66 | + * |
|
67 | + * @return object \lsx\search\classes\facetwp\Post_Connections() A single instance of this class. |
|
68 | + */ |
|
69 | + public static function get_instance() { |
|
70 | + // If the single instance hasn't been set, set it now. |
|
71 | + if ( null === self::$instance ) { |
|
72 | + self::$instance = new self(); |
|
73 | + } |
|
74 | + return self::$instance; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Alter the rows and include extra facets rows for the continents |
|
79 | + */ |
|
80 | + public function facetwp_index_row_data( $rows, $params ) { |
|
81 | + switch ( $params['facet']['source'] ) { |
|
82 | + case 'cf/destination_to_tour': |
|
83 | + case 'cf/destination_to_accommodation': |
|
84 | + $countries = array(); |
|
85 | + |
|
86 | + foreach ( $rows as $r_index => $row ) { |
|
87 | + $parent = wp_get_post_parent_id( $row['facet_value'] ); |
|
88 | + $rows[ $r_index ]['parent_id'] = $parent; |
|
89 | + |
|
90 | + if ( 0 === $parent || '0' === $parent ) { |
|
91 | + if ( ! isset( $countries[ $r_index ] ) ) { |
|
92 | + $countries[ $r_index ] = $row['facet_value']; |
|
93 | + } |
|
94 | + |
|
95 | + if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
96 | + $rows[ $r_index ]['depth'] = 1; |
|
97 | + } else { |
|
98 | + $rows[ $r_index ]['depth'] = 0; |
|
99 | + } |
|
100 | + } else { |
|
101 | + if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
102 | + $rows[ $r_index ]['depth'] = 2; |
|
103 | + } else { |
|
104 | + $rows[ $r_index ]['depth'] = 1; |
|
105 | + } |
|
106 | + } |
|
107 | + } |
|
108 | + if ( ! empty( $this->options['display']['enable_search_continent_filter'] ) ) { |
|
109 | + if ( ! empty( $countries ) ) { |
|
110 | + foreach ( $countries as $row_index => $country ) { |
|
111 | + $continents = wp_get_object_terms( $country, 'continent' ); |
|
112 | + $continent_id = 0; |
|
113 | + |
|
114 | + if ( ! is_wp_error( $continents ) ) { |
|
115 | + $new_row = $params['defaults']; |
|
116 | + if ( ! is_array( $continents ) ) { |
|
117 | + $continents = array( $continents ); |
|
118 | + } |
|
119 | + |
|
120 | + foreach ( $continents as $continent ) { |
|
121 | + $new_row['facet_value'] = $continent->slug; |
|
122 | + $new_row['facet_display_value'] = $continent->name; |
|
123 | + $continent_id = $continent->term_id; |
|
124 | + $new_row['depth'] = 0; |
|
125 | + } |
|
126 | + $rows[] = $new_row; |
|
127 | + $rows[ $row_index ]['parent_id'] = $continent_id; |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | + } |
|
132 | + |
|
133 | + break; |
|
134 | + |
|
135 | + default: |
|
136 | + break; |
|
137 | + } |
|
138 | + |
|
139 | + return $rows; |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Displays the destination specific settings |
|
144 | + */ |
|
145 | + public function facetwp_index_row( $params, $class ) { |
|
146 | + $custom_field = false; |
|
147 | + $meta_key = false; |
|
148 | + |
|
149 | + preg_match( '/cf\//', $class->facet['source'], $custom_field ); |
|
150 | + preg_match( '/_to_/', $class->facet['source'], $meta_key ); |
|
151 | + |
|
152 | + if ( ! empty( $custom_field ) && ! empty( $meta_key ) ) { |
|
153 | + |
|
154 | + if ( ( 'cf/destination_to_accommodation' === $class->facet['source'] || 'cf/destination_to_tour' === $class->facet['source'] ) && ! empty( $this->options['display']['engine_search_continent_filter'] ) && ( '0' === (string) $params['depth'] ) ) { |
|
155 | + $title = ''; |
|
156 | + } else { |
|
157 | + $title = get_the_title( $params['facet_value'] ); |
|
158 | + if ( '' !== $title ) { |
|
159 | + $params['facet_display_value'] = $title; |
|
160 | + } |
|
161 | + if ( '' === $title && ! empty( $meta_key ) ) { |
|
162 | + $params['facet_value'] = ''; |
|
163 | + } |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + // If its a price, save the value as a standard number. |
|
168 | + if ( 'cf/price' === $class->facet['source'] ) { |
|
169 | + $params['facet_value'] = preg_replace( '/[^0-9.]/', '', $params['facet_value'] ); |
|
170 | + $params['facet_value'] = ltrim( $params['facet_value'], '.' ); |
|
171 | + #$params['facet_value'] = number_format( (int) $params['facet_value'], 2 ); |
|
172 | + $params['facet_display_value'] = $params['facet_value']; |
|
173 | + } |
|
174 | + |
|
175 | + // If its a duration, save the value as a standard number. |
|
176 | + if ( 'cf/duration' === $class->facet['source'] ) { |
|
177 | + $params['facet_value'] = preg_replace( '/[^0-9 ]/', '', $params['facet_value'] ); |
|
178 | + $params['facet_value'] = trim( $params['facet_value'] ); |
|
179 | + $params['facet_value'] = explode( ' ', $params['facet_value'] ); |
|
180 | + $params['facet_value'] = $params['facet_value'][0]; |
|
181 | + #$params['facet_value'] = (int) $params['facet_value']; |
|
182 | + $params['facet_display_value'] = $params['facet_value']; |
|
183 | + } |
|
184 | + |
|
185 | + return $params; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Checks the facet source value and outputs the destination facet HTML if needed. |
|
190 | + * |
|
191 | + * @param string $output |
|
192 | + * @param array $params |
|
193 | + * @return string |
|
194 | + */ |
|
195 | + public function destination_facet_html( $output, $params ) { |
|
196 | + $possible_keys = array( |
|
197 | + 'cf/destination_to_accommodation', |
|
198 | + 'cf/destination_to_tour', |
|
199 | + 'cf/destination_to_special', |
|
200 | + 'cf/destination_to_activity', |
|
201 | + 'cf/destination_to_review', |
|
202 | + 'cf/destination_to_vehicle', |
|
203 | + ); |
|
204 | + if ( in_array( $params['facet']['source'], $possible_keys ) ) { |
|
205 | + $output = $this->destination_facet_render( $params ); |
|
206 | + } |
|
207 | + return $output; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Generate the facet HTML |
|
212 | + */ |
|
213 | + public function destination_facet_render( $params ) { |
|
214 | + $facet = $params['facet']; |
|
215 | + |
|
216 | + $output = ''; |
|
217 | + $values = (array) $params['values']; |
|
218 | + $selected_values = (array) $params['selected_values']; |
|
219 | + $soft_limit = empty( $facet['soft_limit'] ) ? 0 : (int) $facet['soft_limit']; |
|
220 | + $countries = array(); |
|
221 | + $continents = array(); |
|
222 | + |
|
223 | + $continent_terms = get_terms( |
|
224 | + array( |
|
225 | + 'taxonomy' => 'continent', |
|
226 | + ) |
|
227 | + ); |
|
228 | + |
|
229 | + if ( ! is_wp_error( $continent_terms ) ) { |
|
230 | + foreach ( $continent_terms as $continent ) { |
|
231 | + $continents[ $continent->term_id ] = $continent->slug; |
|
232 | + } |
|
233 | + } |
|
234 | + |
|
235 | + //Create a relationship of the facet value and the their depths |
|
236 | + $depths = array(); |
|
237 | + $parents = array(); |
|
238 | + foreach ( $values as $value ) { |
|
239 | + $depths[ $value['facet_value'] ] = (int) $value['depth']; |
|
240 | + $parents[ $value['facet_value'] ] = (int) $value['parent_id']; |
|
241 | + } |
|
242 | + |
|
243 | + //Determine the current depth and check if the selected values parents are in the selected array. |
|
244 | + $current_depth = 0; |
|
245 | + $additional_values = array(); |
|
246 | + if ( ! empty( $selected_values ) ) { |
|
247 | + foreach ( $selected_values as $selected ) { |
|
248 | + if ( $depths[ $selected ] > $current_depth ) { |
|
249 | + $current_depth = $depths[ $selected ]; |
|
250 | + } |
|
251 | + } |
|
252 | + $current_depth++; |
|
253 | + } |
|
254 | + |
|
255 | + if ( ! empty( $additional_values ) ) { |
|
256 | + $selected_values = array_merge( $selected_values, $additional_values ); |
|
257 | + } |
|
258 | + |
|
259 | + // This is where the items are sorted by their depth |
|
260 | + $sorted_values = array(); |
|
261 | + $stored = $values; |
|
262 | + |
|
263 | + //sort the options so |
|
264 | + foreach ( $values as $key => $result ) { |
|
265 | + if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
266 | + if ( in_array( $result['facet_value'], $continents ) ) { |
|
267 | + $sorted_values[] = $result; |
|
268 | + $destinations = $this->get_countries( $stored, $result['facet_value'], $continents, '1' ); |
|
269 | + |
|
270 | + if ( ! empty( $destinations ) ) { |
|
271 | + foreach ( $destinations as $destination ) { |
|
272 | + $sorted_values[] = $destination; |
|
273 | + } |
|
274 | + } |
|
275 | + } |
|
276 | + } else { |
|
277 | + if ( '0' === $result['depth'] || 0 === $result['depth'] ) { |
|
278 | + $sorted_values[] = $result; |
|
279 | + $destinations = $this->get_regions( $stored, $result['facet_value'], '1' ); |
|
280 | + |
|
281 | + if ( ! empty( $destinations ) ) { |
|
282 | + foreach ( $destinations as $destination ) { |
|
283 | + $sorted_values[] = $destination; |
|
284 | + } |
|
285 | + } |
|
286 | + } |
|
287 | + } |
|
288 | + } |
|
289 | + $values = $sorted_values; |
|
290 | + |
|
291 | + $continent_class = ''; |
|
292 | + $country_class = ''; |
|
293 | + |
|
294 | + // Run through each value and output the values. |
|
295 | + foreach ( $values as $key => $facet ) { |
|
296 | + $depth_type = ''; |
|
297 | + |
|
298 | + if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
299 | + switch ( $facet['depth'] ) { |
|
300 | + case '0': |
|
301 | + $depth_type = ''; |
|
302 | + $continent_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' continent-checked' : ''; |
|
303 | + break; |
|
304 | + |
|
305 | + case '1': |
|
306 | + $depth_type = 'country' . $continent_class; |
|
307 | + $country_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' country-checked' : ''; |
|
308 | + break; |
|
309 | + |
|
310 | + case '2': |
|
311 | + $depth_type = 'region' . $continent_class . $country_class; |
|
312 | + break; |
|
313 | + } |
|
314 | + } else { |
|
315 | + switch ( $facet['depth'] ) { |
|
316 | + case '0': |
|
317 | + $depth_type = 'country continent-checked'; |
|
318 | + $country_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' country-checked' : ''; |
|
319 | + break; |
|
320 | + |
|
321 | + case '1': |
|
322 | + $depth_type = 'region continent-checked' . $country_class; |
|
323 | + break; |
|
324 | + } |
|
325 | + } |
|
326 | + |
|
327 | + if ( $facet['depth'] <= $current_depth ) { |
|
328 | + $options[] = $this->format_single_facet( $key, $facet, $selected_values, $depth_type ); |
|
329 | + } |
|
330 | + } |
|
331 | + |
|
332 | + if ( ! empty( $options ) ) { |
|
333 | + $output = implode( '', $options ); |
|
334 | + } |
|
335 | + |
|
336 | + return $output; |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * Gets the direct countries from the array. |
|
341 | + */ |
|
342 | + public function get_countries( $values, $parent, $continents, $depth ) { |
|
343 | + $children = array(); |
|
344 | + $stored = $values; |
|
345 | + |
|
346 | + foreach ( $values as $value ) { |
|
347 | + if ( isset( $continents[ $value['parent_id'] ] ) && $continents[ $value['parent_id'] ] === $parent && $value['depth'] === $depth ) { |
|
348 | + $children[] = $value; |
|
349 | + |
|
350 | + $destinations = $this->get_regions( $stored, $value['facet_value'], '2' ); |
|
351 | + if ( ! empty( $destinations ) ) { |
|
352 | + foreach ( $destinations as $destination ) { |
|
353 | + $children[] = $destination; |
|
354 | + } |
|
355 | + } |
|
356 | + } |
|
357 | + } |
|
358 | + return $children; |
|
359 | + } |
|
360 | + |
|
361 | + /** |
|
362 | + * Gets the direct regions from the array. |
|
363 | + */ |
|
364 | + public function get_regions( $values, $parent, $depth ) { |
|
365 | + $children = array(); |
|
366 | + foreach ( $values as $value ) { |
|
367 | + if ( $value['parent_id'] === $parent && $value['depth'] === $depth ) { |
|
368 | + $children[] = $value; |
|
369 | + } |
|
370 | + } |
|
371 | + return $children; |
|
372 | + } |
|
373 | + |
|
374 | + public function format_single_facet( $key, $result, $selected_values, $region = '' ) { |
|
375 | + $temp_html = ''; |
|
376 | + |
|
377 | + $selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : ''; |
|
378 | + $selected .= ( 0 == $result['counter'] && '' == $selected ) ? ' disabled' : ''; |
|
379 | + $selected .= ' ' . $region; |
|
380 | + |
|
381 | + $temp_html .= '<div class="facetwp-checkbox' . $selected . '" data-value="' . $result['facet_value'] . '">'; |
|
382 | + $temp_html .= $result['facet_display_value'] . ' <span class="facetwp-counter">(' . $result['counter'] . ')</span>'; |
|
383 | + $temp_html .= '</div>'; |
|
384 | + |
|
385 | + return $temp_html; |
|
386 | + } |
|
387 | 387 | } |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | 30 | $this->get_cmb2_options(); |
31 | - add_filter( 'facetwp_indexer_row_data', array( $this, 'facetwp_index_row_data' ), 10, 2 ); |
|
32 | - add_filter( 'facetwp_index_row', array( $this, 'facetwp_index_row' ), 10, 2 ); |
|
33 | - add_filter( 'facetwp_facet_html', array( $this, 'destination_facet_html' ), 10, 2 ); |
|
31 | + add_filter('facetwp_indexer_row_data', array($this, 'facetwp_index_row_data'), 10, 2); |
|
32 | + add_filter('facetwp_index_row', array($this, 'facetwp_index_row'), 10, 2); |
|
33 | + add_filter('facetwp_facet_html', array($this, 'destination_facet_html'), 10, 2); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | * @return void |
40 | 40 | */ |
41 | 41 | private function get_cmb2_options() { |
42 | - $cmb2_options = get_option( 'lsx-search-settings' ); |
|
43 | - if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
42 | + $cmb2_options = get_option('lsx-search-settings'); |
|
43 | + if (false !== $cmb2_options && !empty($cmb2_options)) { |
|
44 | 44 | $this->options['display'] = $cmb2_options; |
45 | - foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
46 | - if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
45 | + foreach ($this->options['display'] as $option_key => $option_value) { |
|
46 | + if (is_array($option_value) && !empty($option_value)) { |
|
47 | 47 | $new_values = array(); |
48 | - foreach ( $option_value as $empty_key => $key_value ) { |
|
49 | - $new_values[ $key_value ] = 'on'; |
|
48 | + foreach ($option_value as $empty_key => $key_value) { |
|
49 | + $new_values[$key_value] = 'on'; |
|
50 | 50 | } |
51 | - $this->options['display'][ $option_key ] = $new_values; |
|
51 | + $this->options['display'][$option_key] = $new_values; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public static function get_instance() { |
70 | 70 | // If the single instance hasn't been set, set it now. |
71 | - if ( null === self::$instance ) { |
|
71 | + if (null === self::$instance) { |
|
72 | 72 | self::$instance = new self(); |
73 | 73 | } |
74 | 74 | return self::$instance; |
@@ -77,54 +77,54 @@ discard block |
||
77 | 77 | /** |
78 | 78 | * Alter the rows and include extra facets rows for the continents |
79 | 79 | */ |
80 | - public function facetwp_index_row_data( $rows, $params ) { |
|
81 | - switch ( $params['facet']['source'] ) { |
|
80 | + public function facetwp_index_row_data($rows, $params) { |
|
81 | + switch ($params['facet']['source']) { |
|
82 | 82 | case 'cf/destination_to_tour': |
83 | 83 | case 'cf/destination_to_accommodation': |
84 | 84 | $countries = array(); |
85 | 85 | |
86 | - foreach ( $rows as $r_index => $row ) { |
|
87 | - $parent = wp_get_post_parent_id( $row['facet_value'] ); |
|
88 | - $rows[ $r_index ]['parent_id'] = $parent; |
|
86 | + foreach ($rows as $r_index => $row) { |
|
87 | + $parent = wp_get_post_parent_id($row['facet_value']); |
|
88 | + $rows[$r_index]['parent_id'] = $parent; |
|
89 | 89 | |
90 | - if ( 0 === $parent || '0' === $parent ) { |
|
91 | - if ( ! isset( $countries[ $r_index ] ) ) { |
|
92 | - $countries[ $r_index ] = $row['facet_value']; |
|
90 | + if (0 === $parent || '0' === $parent) { |
|
91 | + if (!isset($countries[$r_index])) { |
|
92 | + $countries[$r_index] = $row['facet_value']; |
|
93 | 93 | } |
94 | 94 | |
95 | - if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
96 | - $rows[ $r_index ]['depth'] = 1; |
|
95 | + if (!empty($this->options['display']['engine_search_continent_filter'])) { |
|
96 | + $rows[$r_index]['depth'] = 1; |
|
97 | 97 | } else { |
98 | - $rows[ $r_index ]['depth'] = 0; |
|
98 | + $rows[$r_index]['depth'] = 0; |
|
99 | 99 | } |
100 | 100 | } else { |
101 | - if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
102 | - $rows[ $r_index ]['depth'] = 2; |
|
101 | + if (!empty($this->options['display']['engine_search_continent_filter'])) { |
|
102 | + $rows[$r_index]['depth'] = 2; |
|
103 | 103 | } else { |
104 | - $rows[ $r_index ]['depth'] = 1; |
|
104 | + $rows[$r_index]['depth'] = 1; |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | - if ( ! empty( $this->options['display']['enable_search_continent_filter'] ) ) { |
|
109 | - if ( ! empty( $countries ) ) { |
|
110 | - foreach ( $countries as $row_index => $country ) { |
|
111 | - $continents = wp_get_object_terms( $country, 'continent' ); |
|
108 | + if (!empty($this->options['display']['enable_search_continent_filter'])) { |
|
109 | + if (!empty($countries)) { |
|
110 | + foreach ($countries as $row_index => $country) { |
|
111 | + $continents = wp_get_object_terms($country, 'continent'); |
|
112 | 112 | $continent_id = 0; |
113 | 113 | |
114 | - if ( ! is_wp_error( $continents ) ) { |
|
114 | + if (!is_wp_error($continents)) { |
|
115 | 115 | $new_row = $params['defaults']; |
116 | - if ( ! is_array( $continents ) ) { |
|
117 | - $continents = array( $continents ); |
|
116 | + if (!is_array($continents)) { |
|
117 | + $continents = array($continents); |
|
118 | 118 | } |
119 | 119 | |
120 | - foreach ( $continents as $continent ) { |
|
120 | + foreach ($continents as $continent) { |
|
121 | 121 | $new_row['facet_value'] = $continent->slug; |
122 | 122 | $new_row['facet_display_value'] = $continent->name; |
123 | 123 | $continent_id = $continent->term_id; |
124 | 124 | $new_row['depth'] = 0; |
125 | 125 | } |
126 | 126 | $rows[] = $new_row; |
127 | - $rows[ $row_index ]['parent_id'] = $continent_id; |
|
127 | + $rows[$row_index]['parent_id'] = $continent_id; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
@@ -142,41 +142,41 @@ discard block |
||
142 | 142 | /** |
143 | 143 | * Displays the destination specific settings |
144 | 144 | */ |
145 | - public function facetwp_index_row( $params, $class ) { |
|
145 | + public function facetwp_index_row($params, $class) { |
|
146 | 146 | $custom_field = false; |
147 | 147 | $meta_key = false; |
148 | 148 | |
149 | - preg_match( '/cf\//', $class->facet['source'], $custom_field ); |
|
150 | - preg_match( '/_to_/', $class->facet['source'], $meta_key ); |
|
149 | + preg_match('/cf\//', $class->facet['source'], $custom_field); |
|
150 | + preg_match('/_to_/', $class->facet['source'], $meta_key); |
|
151 | 151 | |
152 | - if ( ! empty( $custom_field ) && ! empty( $meta_key ) ) { |
|
152 | + if (!empty($custom_field) && !empty($meta_key)) { |
|
153 | 153 | |
154 | - if ( ( 'cf/destination_to_accommodation' === $class->facet['source'] || 'cf/destination_to_tour' === $class->facet['source'] ) && ! empty( $this->options['display']['engine_search_continent_filter'] ) && ( '0' === (string) $params['depth'] ) ) { |
|
154 | + if (('cf/destination_to_accommodation' === $class->facet['source'] || 'cf/destination_to_tour' === $class->facet['source']) && !empty($this->options['display']['engine_search_continent_filter']) && ('0' === (string) $params['depth'])) { |
|
155 | 155 | $title = ''; |
156 | 156 | } else { |
157 | - $title = get_the_title( $params['facet_value'] ); |
|
158 | - if ( '' !== $title ) { |
|
157 | + $title = get_the_title($params['facet_value']); |
|
158 | + if ('' !== $title) { |
|
159 | 159 | $params['facet_display_value'] = $title; |
160 | 160 | } |
161 | - if ( '' === $title && ! empty( $meta_key ) ) { |
|
161 | + if ('' === $title && !empty($meta_key)) { |
|
162 | 162 | $params['facet_value'] = ''; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | 167 | // If its a price, save the value as a standard number. |
168 | - if ( 'cf/price' === $class->facet['source'] ) { |
|
169 | - $params['facet_value'] = preg_replace( '/[^0-9.]/', '', $params['facet_value'] ); |
|
170 | - $params['facet_value'] = ltrim( $params['facet_value'], '.' ); |
|
168 | + if ('cf/price' === $class->facet['source']) { |
|
169 | + $params['facet_value'] = preg_replace('/[^0-9.]/', '', $params['facet_value']); |
|
170 | + $params['facet_value'] = ltrim($params['facet_value'], '.'); |
|
171 | 171 | #$params['facet_value'] = number_format( (int) $params['facet_value'], 2 ); |
172 | 172 | $params['facet_display_value'] = $params['facet_value']; |
173 | 173 | } |
174 | 174 | |
175 | 175 | // If its a duration, save the value as a standard number. |
176 | - if ( 'cf/duration' === $class->facet['source'] ) { |
|
177 | - $params['facet_value'] = preg_replace( '/[^0-9 ]/', '', $params['facet_value'] ); |
|
178 | - $params['facet_value'] = trim( $params['facet_value'] ); |
|
179 | - $params['facet_value'] = explode( ' ', $params['facet_value'] ); |
|
176 | + if ('cf/duration' === $class->facet['source']) { |
|
177 | + $params['facet_value'] = preg_replace('/[^0-9 ]/', '', $params['facet_value']); |
|
178 | + $params['facet_value'] = trim($params['facet_value']); |
|
179 | + $params['facet_value'] = explode(' ', $params['facet_value']); |
|
180 | 180 | $params['facet_value'] = $params['facet_value'][0]; |
181 | 181 | #$params['facet_value'] = (int) $params['facet_value']; |
182 | 182 | $params['facet_display_value'] = $params['facet_value']; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param array $params |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - public function destination_facet_html( $output, $params ) { |
|
195 | + public function destination_facet_html($output, $params) { |
|
196 | 196 | $possible_keys = array( |
197 | 197 | 'cf/destination_to_accommodation', |
198 | 198 | 'cf/destination_to_tour', |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | 'cf/destination_to_review', |
202 | 202 | 'cf/destination_to_vehicle', |
203 | 203 | ); |
204 | - if ( in_array( $params['facet']['source'], $possible_keys ) ) { |
|
205 | - $output = $this->destination_facet_render( $params ); |
|
204 | + if (in_array($params['facet']['source'], $possible_keys)) { |
|
205 | + $output = $this->destination_facet_render($params); |
|
206 | 206 | } |
207 | 207 | return $output; |
208 | 208 | } |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * Generate the facet HTML |
212 | 212 | */ |
213 | - public function destination_facet_render( $params ) { |
|
213 | + public function destination_facet_render($params) { |
|
214 | 214 | $facet = $params['facet']; |
215 | 215 | |
216 | 216 | $output = ''; |
217 | 217 | $values = (array) $params['values']; |
218 | 218 | $selected_values = (array) $params['selected_values']; |
219 | - $soft_limit = empty( $facet['soft_limit'] ) ? 0 : (int) $facet['soft_limit']; |
|
219 | + $soft_limit = empty($facet['soft_limit']) ? 0 : (int) $facet['soft_limit']; |
|
220 | 220 | $countries = array(); |
221 | 221 | $continents = array(); |
222 | 222 | |
@@ -226,34 +226,34 @@ discard block |
||
226 | 226 | ) |
227 | 227 | ); |
228 | 228 | |
229 | - if ( ! is_wp_error( $continent_terms ) ) { |
|
230 | - foreach ( $continent_terms as $continent ) { |
|
231 | - $continents[ $continent->term_id ] = $continent->slug; |
|
229 | + if (!is_wp_error($continent_terms)) { |
|
230 | + foreach ($continent_terms as $continent) { |
|
231 | + $continents[$continent->term_id] = $continent->slug; |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | 235 | //Create a relationship of the facet value and the their depths |
236 | 236 | $depths = array(); |
237 | 237 | $parents = array(); |
238 | - foreach ( $values as $value ) { |
|
239 | - $depths[ $value['facet_value'] ] = (int) $value['depth']; |
|
240 | - $parents[ $value['facet_value'] ] = (int) $value['parent_id']; |
|
238 | + foreach ($values as $value) { |
|
239 | + $depths[$value['facet_value']] = (int) $value['depth']; |
|
240 | + $parents[$value['facet_value']] = (int) $value['parent_id']; |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | //Determine the current depth and check if the selected values parents are in the selected array. |
244 | 244 | $current_depth = 0; |
245 | 245 | $additional_values = array(); |
246 | - if ( ! empty( $selected_values ) ) { |
|
247 | - foreach ( $selected_values as $selected ) { |
|
248 | - if ( $depths[ $selected ] > $current_depth ) { |
|
249 | - $current_depth = $depths[ $selected ]; |
|
246 | + if (!empty($selected_values)) { |
|
247 | + foreach ($selected_values as $selected) { |
|
248 | + if ($depths[$selected] > $current_depth) { |
|
249 | + $current_depth = $depths[$selected]; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | $current_depth++; |
253 | 253 | } |
254 | 254 | |
255 | - if ( ! empty( $additional_values ) ) { |
|
256 | - $selected_values = array_merge( $selected_values, $additional_values ); |
|
255 | + if (!empty($additional_values)) { |
|
256 | + $selected_values = array_merge($selected_values, $additional_values); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | // This is where the items are sorted by their depth |
@@ -261,25 +261,25 @@ discard block |
||
261 | 261 | $stored = $values; |
262 | 262 | |
263 | 263 | //sort the options so |
264 | - foreach ( $values as $key => $result ) { |
|
265 | - if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
266 | - if ( in_array( $result['facet_value'], $continents ) ) { |
|
264 | + foreach ($values as $key => $result) { |
|
265 | + if (!empty($this->options['display']['engine_search_continent_filter'])) { |
|
266 | + if (in_array($result['facet_value'], $continents)) { |
|
267 | 267 | $sorted_values[] = $result; |
268 | - $destinations = $this->get_countries( $stored, $result['facet_value'], $continents, '1' ); |
|
268 | + $destinations = $this->get_countries($stored, $result['facet_value'], $continents, '1'); |
|
269 | 269 | |
270 | - if ( ! empty( $destinations ) ) { |
|
271 | - foreach ( $destinations as $destination ) { |
|
270 | + if (!empty($destinations)) { |
|
271 | + foreach ($destinations as $destination) { |
|
272 | 272 | $sorted_values[] = $destination; |
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
276 | 276 | } else { |
277 | - if ( '0' === $result['depth'] || 0 === $result['depth'] ) { |
|
277 | + if ('0' === $result['depth'] || 0 === $result['depth']) { |
|
278 | 278 | $sorted_values[] = $result; |
279 | - $destinations = $this->get_regions( $stored, $result['facet_value'], '1' ); |
|
279 | + $destinations = $this->get_regions($stored, $result['facet_value'], '1'); |
|
280 | 280 | |
281 | - if ( ! empty( $destinations ) ) { |
|
282 | - foreach ( $destinations as $destination ) { |
|
281 | + if (!empty($destinations)) { |
|
282 | + foreach ($destinations as $destination) { |
|
283 | 283 | $sorted_values[] = $destination; |
284 | 284 | } |
285 | 285 | } |
@@ -292,45 +292,45 @@ discard block |
||
292 | 292 | $country_class = ''; |
293 | 293 | |
294 | 294 | // Run through each value and output the values. |
295 | - foreach ( $values as $key => $facet ) { |
|
295 | + foreach ($values as $key => $facet) { |
|
296 | 296 | $depth_type = ''; |
297 | 297 | |
298 | - if ( ! empty( $this->options['display']['engine_search_continent_filter'] ) ) { |
|
299 | - switch ( $facet['depth'] ) { |
|
298 | + if (!empty($this->options['display']['engine_search_continent_filter'])) { |
|
299 | + switch ($facet['depth']) { |
|
300 | 300 | case '0': |
301 | 301 | $depth_type = ''; |
302 | - $continent_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' continent-checked' : ''; |
|
302 | + $continent_class = in_array($facet['facet_value'], $selected_values) ? $depth_type .= ' continent-checked' : ''; |
|
303 | 303 | break; |
304 | 304 | |
305 | 305 | case '1': |
306 | - $depth_type = 'country' . $continent_class; |
|
307 | - $country_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' country-checked' : ''; |
|
306 | + $depth_type = 'country'.$continent_class; |
|
307 | + $country_class = in_array($facet['facet_value'], $selected_values) ? $depth_type .= ' country-checked' : ''; |
|
308 | 308 | break; |
309 | 309 | |
310 | 310 | case '2': |
311 | - $depth_type = 'region' . $continent_class . $country_class; |
|
311 | + $depth_type = 'region'.$continent_class.$country_class; |
|
312 | 312 | break; |
313 | 313 | } |
314 | 314 | } else { |
315 | - switch ( $facet['depth'] ) { |
|
315 | + switch ($facet['depth']) { |
|
316 | 316 | case '0': |
317 | 317 | $depth_type = 'country continent-checked'; |
318 | - $country_class = in_array( $facet['facet_value'], $selected_values ) ? $depth_type .= ' country-checked' : ''; |
|
318 | + $country_class = in_array($facet['facet_value'], $selected_values) ? $depth_type .= ' country-checked' : ''; |
|
319 | 319 | break; |
320 | 320 | |
321 | 321 | case '1': |
322 | - $depth_type = 'region continent-checked' . $country_class; |
|
322 | + $depth_type = 'region continent-checked'.$country_class; |
|
323 | 323 | break; |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | - if ( $facet['depth'] <= $current_depth ) { |
|
328 | - $options[] = $this->format_single_facet( $key, $facet, $selected_values, $depth_type ); |
|
327 | + if ($facet['depth'] <= $current_depth) { |
|
328 | + $options[] = $this->format_single_facet($key, $facet, $selected_values, $depth_type); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - if ( ! empty( $options ) ) { |
|
333 | - $output = implode( '', $options ); |
|
332 | + if (!empty($options)) { |
|
333 | + $output = implode('', $options); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | return $output; |
@@ -339,17 +339,17 @@ discard block |
||
339 | 339 | /** |
340 | 340 | * Gets the direct countries from the array. |
341 | 341 | */ |
342 | - public function get_countries( $values, $parent, $continents, $depth ) { |
|
342 | + public function get_countries($values, $parent, $continents, $depth) { |
|
343 | 343 | $children = array(); |
344 | 344 | $stored = $values; |
345 | 345 | |
346 | - foreach ( $values as $value ) { |
|
347 | - if ( isset( $continents[ $value['parent_id'] ] ) && $continents[ $value['parent_id'] ] === $parent && $value['depth'] === $depth ) { |
|
346 | + foreach ($values as $value) { |
|
347 | + if (isset($continents[$value['parent_id']]) && $continents[$value['parent_id']] === $parent && $value['depth'] === $depth) { |
|
348 | 348 | $children[] = $value; |
349 | 349 | |
350 | - $destinations = $this->get_regions( $stored, $value['facet_value'], '2' ); |
|
351 | - if ( ! empty( $destinations ) ) { |
|
352 | - foreach ( $destinations as $destination ) { |
|
350 | + $destinations = $this->get_regions($stored, $value['facet_value'], '2'); |
|
351 | + if (!empty($destinations)) { |
|
352 | + foreach ($destinations as $destination) { |
|
353 | 353 | $children[] = $destination; |
354 | 354 | } |
355 | 355 | } |
@@ -361,25 +361,25 @@ discard block |
||
361 | 361 | /** |
362 | 362 | * Gets the direct regions from the array. |
363 | 363 | */ |
364 | - public function get_regions( $values, $parent, $depth ) { |
|
364 | + public function get_regions($values, $parent, $depth) { |
|
365 | 365 | $children = array(); |
366 | - foreach ( $values as $value ) { |
|
367 | - if ( $value['parent_id'] === $parent && $value['depth'] === $depth ) { |
|
366 | + foreach ($values as $value) { |
|
367 | + if ($value['parent_id'] === $parent && $value['depth'] === $depth) { |
|
368 | 368 | $children[] = $value; |
369 | 369 | } |
370 | 370 | } |
371 | 371 | return $children; |
372 | 372 | } |
373 | 373 | |
374 | - public function format_single_facet( $key, $result, $selected_values, $region = '' ) { |
|
374 | + public function format_single_facet($key, $result, $selected_values, $region = '') { |
|
375 | 375 | $temp_html = ''; |
376 | 376 | |
377 | - $selected = in_array( $result['facet_value'], $selected_values ) ? ' checked' : ''; |
|
378 | - $selected .= ( 0 == $result['counter'] && '' == $selected ) ? ' disabled' : ''; |
|
379 | - $selected .= ' ' . $region; |
|
377 | + $selected = in_array($result['facet_value'], $selected_values) ? ' checked' : ''; |
|
378 | + $selected .= (0 == $result['counter'] && '' == $selected) ? ' disabled' : ''; |
|
379 | + $selected .= ' '.$region; |
|
380 | 380 | |
381 | - $temp_html .= '<div class="facetwp-checkbox' . $selected . '" data-value="' . $result['facet_value'] . '">'; |
|
382 | - $temp_html .= $result['facet_display_value'] . ' <span class="facetwp-counter">(' . $result['counter'] . ')</span>'; |
|
381 | + $temp_html .= '<div class="facetwp-checkbox'.$selected.'" data-value="'.$result['facet_value'].'">'; |
|
382 | + $temp_html .= $result['facet_display_value'].' <span class="facetwp-counter">('.$result['counter'].')</span>'; |
|
383 | 383 | $temp_html .= '</div>'; |
384 | 384 | |
385 | 385 | return $temp_html; |
@@ -6,86 +6,86 @@ discard block |
||
6 | 6 | */ |
7 | 7 | class LSX_Search_Shortcode { |
8 | 8 | |
9 | - /** |
|
10 | - * Construct method. |
|
11 | - */ |
|
12 | - public function __construct() { |
|
13 | - add_shortcode( 'lsx_search_form', array( $this, 'search_form' ) ); |
|
14 | - } |
|
9 | + /** |
|
10 | + * Construct method. |
|
11 | + */ |
|
12 | + public function __construct() { |
|
13 | + add_shortcode( 'lsx_search_form', array( $this, 'search_form' ) ); |
|
14 | + } |
|
15 | 15 | |
16 | - /** |
|
17 | - * Outputs the appropriate search form |
|
18 | - */ |
|
19 | - public function search_form( $atts = array() ) { |
|
20 | - $classes = 'search-form lsx-search-form form-inline'; |
|
16 | + /** |
|
17 | + * Outputs the appropriate search form |
|
18 | + */ |
|
19 | + public function search_form( $atts = array() ) { |
|
20 | + $classes = 'search-form lsx-search-form form-inline'; |
|
21 | 21 | |
22 | - if ( isset( $atts['class'] ) ) { |
|
23 | - $classes .= $atts['class']; |
|
24 | - } |
|
22 | + if ( isset( $atts['class'] ) ) { |
|
23 | + $classes .= $atts['class']; |
|
24 | + } |
|
25 | 25 | |
26 | - $placeholder = __( 'Where do you want to go?', 'lsx-search' ); |
|
26 | + $placeholder = __( 'Where do you want to go?', 'lsx-search' ); |
|
27 | 27 | |
28 | - if ( isset( $atts['placeholder'] ) ) { |
|
29 | - $placeholder = $atts['placeholder']; |
|
30 | - } |
|
28 | + if ( isset( $atts['placeholder'] ) ) { |
|
29 | + $placeholder = $atts['placeholder']; |
|
30 | + } |
|
31 | 31 | |
32 | - $action = '/'; |
|
32 | + $action = '/'; |
|
33 | 33 | |
34 | - if ( isset( $atts['action'] ) ) { |
|
35 | - $action = $atts['action']; |
|
36 | - } |
|
34 | + if ( isset( $atts['action'] ) ) { |
|
35 | + $action = $atts['action']; |
|
36 | + } |
|
37 | 37 | |
38 | - $method = 'get'; |
|
38 | + $method = 'get'; |
|
39 | 39 | |
40 | - if ( isset( $atts['method'] ) ) { |
|
41 | - $method = $atts['method']; |
|
42 | - } |
|
40 | + if ( isset( $atts['method'] ) ) { |
|
41 | + $method = $atts['method']; |
|
42 | + } |
|
43 | 43 | |
44 | - $button_label = __( 'Search', 'lsx-search' ); |
|
44 | + $button_label = __( 'Search', 'lsx-search' ); |
|
45 | 45 | |
46 | - if ( isset( $atts['button_label'] ) ) { |
|
47 | - $button_label = $atts['button_label']; |
|
48 | - } |
|
46 | + if ( isset( $atts['button_label'] ) ) { |
|
47 | + $button_label = $atts['button_label']; |
|
48 | + } |
|
49 | 49 | |
50 | - $button_class = 'btn cta-btn '; |
|
50 | + $button_class = 'btn cta-btn '; |
|
51 | 51 | |
52 | - if ( isset( $atts['button_class'] ) ) { |
|
53 | - $button_class .= $atts['button_class']; |
|
54 | - } |
|
52 | + if ( isset( $atts['button_class'] ) ) { |
|
53 | + $button_class .= $atts['button_class']; |
|
54 | + } |
|
55 | 55 | |
56 | - $engine = false; |
|
56 | + $engine = false; |
|
57 | 57 | |
58 | - if ( isset( $atts['engine'] ) ) { |
|
59 | - $engine = $atts['engine']; |
|
60 | - } |
|
58 | + if ( isset( $atts['engine'] ) ) { |
|
59 | + $engine = $atts['engine']; |
|
60 | + } |
|
61 | 61 | |
62 | - $engine_select = false; |
|
62 | + $engine_select = false; |
|
63 | 63 | |
64 | - if ( isset( $atts['engine_select'] ) ) { |
|
65 | - $engine_select = true; |
|
66 | - } |
|
64 | + if ( isset( $atts['engine_select'] ) ) { |
|
65 | + $engine_select = true; |
|
66 | + } |
|
67 | 67 | |
68 | - $display_search_field = true; |
|
68 | + $display_search_field = true; |
|
69 | 69 | |
70 | - if ( isset( $atts['search_field'] ) ) { |
|
71 | - $display_search_field = (boolean) $atts['search_field']; |
|
72 | - } |
|
70 | + if ( isset( $atts['search_field'] ) ) { |
|
71 | + $display_search_field = (boolean) $atts['search_field']; |
|
72 | + } |
|
73 | 73 | |
74 | - $facets = false; |
|
74 | + $facets = false; |
|
75 | 75 | |
76 | - if ( isset( $atts['facets'] ) ) { |
|
77 | - $facets = $atts['facets']; |
|
78 | - } |
|
76 | + if ( isset( $atts['facets'] ) ) { |
|
77 | + $facets = $atts['facets']; |
|
78 | + } |
|
79 | 79 | |
80 | - $combo_box = false; |
|
80 | + $combo_box = false; |
|
81 | 81 | |
82 | - if ( isset( $atts['combo_box'] ) ) { |
|
83 | - $combo_box = true; |
|
84 | - } |
|
82 | + if ( isset( $atts['combo_box'] ) ) { |
|
83 | + $combo_box = true; |
|
84 | + } |
|
85 | 85 | |
86 | - $return = ''; |
|
86 | + $return = ''; |
|
87 | 87 | |
88 | - ob_start(); ?> |
|
88 | + ob_start(); ?> |
|
89 | 89 | |
90 | 90 | <?php do_action( 'lsx_search_form_before' ); ?> |
91 | 91 | |
@@ -103,62 +103,62 @@ discard block |
||
103 | 103 | <?php endif; ?> |
104 | 104 | |
105 | 105 | <?php if ( false !== $engine_select && false !== $engine && 'default' !== $engine ) : |
106 | - $engines = explode( '|',$engine ); ?> |
|
106 | + $engines = explode( '|',$engine ); ?> |
|
107 | 107 | <div class="field engine-select"> |
108 | 108 | <div class="dropdown nav-item"> |
109 | 109 | <?php |
110 | - $plural = 's'; |
|
111 | - if ( 'accommodation' === $engine[0] ) { |
|
112 | - $plural = ''; |
|
113 | - } |
|
114 | - ?> |
|
110 | + $plural = 's'; |
|
111 | + if ( 'accommodation' === $engine[0] ) { |
|
112 | + $plural = ''; |
|
113 | + } |
|
114 | + ?> |
|
115 | 115 | <button id="engine" data-selection="<?php echo esc_attr( $engines[0] ); ?>" class="btn border-btn btn-dropdown dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo esc_html( ucwords( str_replace( '_', ' ',$engines[0] ) ) . $plural ); ?> <span class="caret"></span></button> |
116 | 116 | <ul class="dropdown-menu"> |
117 | 117 | <?php |
118 | - foreach ( $engines as $engine ) { |
|
119 | - $plural = 's'; |
|
120 | - if ( 'accommodation' === $engine ) { |
|
121 | - $plural = ''; |
|
122 | - } |
|
123 | - echo '<li><a data-value="' . esc_attr( $engine ) . '" href="#">' . esc_html( ucfirst( str_replace( '_', ' ',$engine ) ) . $plural ) . '</a></li>'; |
|
124 | - } |
|
125 | - ?> |
|
118 | + foreach ( $engines as $engine ) { |
|
119 | + $plural = 's'; |
|
120 | + if ( 'accommodation' === $engine ) { |
|
121 | + $plural = ''; |
|
122 | + } |
|
123 | + echo '<li><a data-value="' . esc_attr( $engine ) . '" href="#">' . esc_html( ucfirst( str_replace( '_', ' ',$engine ) ) . $plural ) . '</a></li>'; |
|
124 | + } |
|
125 | + ?> |
|
126 | 126 | </ul> |
127 | 127 | </div> |
128 | 128 | </div> |
129 | 129 | <?php endif; ?> |
130 | 130 | |
131 | 131 | <?php if ( false !== $facets ) { |
132 | - $facets = explode( '|',$facets ); |
|
132 | + $facets = explode( '|',$facets ); |
|
133 | 133 | |
134 | - if ( ! is_array( $facets ) ) { |
|
135 | - $facets = array( $facets ); |
|
136 | - } |
|
134 | + if ( ! is_array( $facets ) ) { |
|
135 | + $facets = array( $facets ); |
|
136 | + } |
|
137 | 137 | |
138 | - $field_class = 'field'; |
|
138 | + $field_class = 'field'; |
|
139 | 139 | |
140 | - if ( false !== $combo_box ) { |
|
141 | - $this->combo_box( $facets ); |
|
142 | - $field_class .= ' combination-toggle hidden'; |
|
143 | - } |
|
140 | + if ( false !== $combo_box ) { |
|
141 | + $this->combo_box( $facets ); |
|
142 | + $field_class .= ' combination-toggle hidden'; |
|
143 | + } |
|
144 | 144 | |
145 | - foreach ( $facets as $facet ) { |
|
146 | - ?> |
|
145 | + foreach ( $facets as $facet ) { |
|
146 | + ?> |
|
147 | 147 | <div class="<?php echo wp_kses_post( $field_class ); ?>"> |
148 | 148 | <?php |
149 | - $facet = FWP()->helper->get_facet_by_name( $facet ); |
|
150 | - if ( isset( $facet['source'] ) ) { |
|
151 | - $values = $this->get_form_facet( $facet['source'] ); |
|
152 | - } else { |
|
153 | - $values = array(); |
|
154 | - } |
|
155 | - $facet_display_type = apply_filters( 'lsx_search_form_field_type', 'select', $facet ); |
|
156 | - $this->display_form_field( $facet_display_type,$facet,$values,$combo_box ); |
|
157 | - ?> |
|
149 | + $facet = FWP()->helper->get_facet_by_name( $facet ); |
|
150 | + if ( isset( $facet['source'] ) ) { |
|
151 | + $values = $this->get_form_facet( $facet['source'] ); |
|
152 | + } else { |
|
153 | + $values = array(); |
|
154 | + } |
|
155 | + $facet_display_type = apply_filters( 'lsx_search_form_field_type', 'select', $facet ); |
|
156 | + $this->display_form_field( $facet_display_type,$facet,$values,$combo_box ); |
|
157 | + ?> |
|
158 | 158 | </div> |
159 | 159 | <?php |
160 | - } |
|
161 | - } ?> |
|
160 | + } |
|
161 | + } ?> |
|
162 | 162 | |
163 | 163 | <div class="field submit-button"> |
164 | 164 | <button class="<?php echo esc_attr( $button_class ); ?>" type="submit"><?php echo wp_kses_post( $button_label ); ?></button> |
@@ -177,19 +177,19 @@ discard block |
||
177 | 177 | |
178 | 178 | <?php do_action( 'lsx_search_form_after' ); ?> |
179 | 179 | <?php |
180 | - $return = ob_get_clean(); |
|
180 | + $return = ob_get_clean(); |
|
181 | 181 | |
182 | - $return = preg_replace( '/[\n]+/', ' ', $return ); |
|
183 | - $return = preg_replace( '/[\t]+/', ' ', $return ); |
|
182 | + $return = preg_replace( '/[\n]+/', ' ', $return ); |
|
183 | + $return = preg_replace( '/[\t]+/', ' ', $return ); |
|
184 | 184 | |
185 | - return $return; |
|
186 | - } |
|
185 | + return $return; |
|
186 | + } |
|
187 | 187 | |
188 | - /** |
|
189 | - * Outputs the combination selector |
|
190 | - */ |
|
191 | - public function combo_box( $facets ) { |
|
192 | - ?> |
|
188 | + /** |
|
189 | + * Outputs the combination selector |
|
190 | + */ |
|
191 | + public function combo_box( $facets ) { |
|
192 | + ?> |
|
193 | 193 | <div class="field combination-dropdown"> |
194 | 194 | <div class="dropdown"> |
195 | 195 | <button data-selection="0" class="btn border-btn btn-dropdown dropdown-toggle btn-combination" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> |
@@ -201,65 +201,65 @@ discard block |
||
201 | 201 | <li style="display: none;"><a class="default" data-value="0" href="#"><?php esc_attr_e( 'Select ', 'lsx-search' ); ?></a></li> |
202 | 202 | |
203 | 203 | <?php foreach ( $facets as $facet ) { |
204 | - $facet = FWP()->helper->get_facet_by_name( $facet ); |
|
205 | - ?> |
|
204 | + $facet = FWP()->helper->get_facet_by_name( $facet ); |
|
205 | + ?> |
|
206 | 206 | <li><a data-value="fwp_<?php echo wp_kses_post( $facet['name'] ); ?>" href="#"><?php echo wp_kses_post( $facet['label'] ); ?></a></li> |
207 | 207 | <?php } ?> |
208 | 208 | </ul> |
209 | 209 | </div> |
210 | 210 | </div> |
211 | 211 | <?php |
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * Grabs the Values for the Facet in Question. |
|
216 | - */ |
|
217 | - protected function get_form_facet( $facet_source = false ) { |
|
218 | - global $wpdb; |
|
219 | - |
|
220 | - $values = array(); |
|
221 | - $select = 'f.facet_value, f.facet_display_value'; |
|
222 | - $from = "{$wpdb->prefix}facetwp_index f"; |
|
223 | - $where = "f.facet_source = '{$facet_source}'"; |
|
224 | - |
|
225 | - //Check if the current facet is showing destinations. |
|
226 | - if ( stripos( $facet_source, 'destination_to' ) ) { |
|
227 | - $from .= " INNER JOIN {$wpdb->posts} p ON f.facet_value = p.ID"; |
|
228 | - $where .= " AND p.post_parent = '0'"; |
|
229 | - |
|
230 | - } |
|
231 | - |
|
232 | - $response = $wpdb->prepare( "SELECT {$select} FROM {$from} WHERE {$where}" );// WPCS: unprepared SQL OK. |
|
233 | - |
|
234 | - if ( ! empty( $response ) ) { |
|
235 | - foreach ( $response as $re ) { |
|
236 | - $display_value = $re->facet_display_value; |
|
237 | - if ( function_exists( 'pll_translate_string' ) ) { |
|
238 | - $current_lang = pll_current_language(); |
|
239 | - $display_value = pll_translate_string( $display_value, $current_lang ); |
|
240 | - } |
|
241 | - $display_value = apply_filters( 'lsx_search_facetwp_display_value', $display_value, $re->facet_value ); |
|
242 | - $values[ $re->facet_value ] = $display_value; |
|
243 | - } |
|
244 | - } |
|
245 | - |
|
246 | - asort( $values ); |
|
247 | - return $values; |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Change FaceWP pagination HTML to be equal main pagination (WP-PageNavi) |
|
252 | - */ |
|
253 | - public function display_form_field( $type = 'select', $facet = array(), $values = array(), $combo = false ) { |
|
254 | - if ( empty( $facet ) ) { |
|
255 | - return; |
|
256 | - } |
|
257 | - |
|
258 | - $source = 'fwp_' . $facet['name']; |
|
259 | - |
|
260 | - switch ( $type ) { |
|
261 | - |
|
262 | - case 'select': ?> |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * Grabs the Values for the Facet in Question. |
|
216 | + */ |
|
217 | + protected function get_form_facet( $facet_source = false ) { |
|
218 | + global $wpdb; |
|
219 | + |
|
220 | + $values = array(); |
|
221 | + $select = 'f.facet_value, f.facet_display_value'; |
|
222 | + $from = "{$wpdb->prefix}facetwp_index f"; |
|
223 | + $where = "f.facet_source = '{$facet_source}'"; |
|
224 | + |
|
225 | + //Check if the current facet is showing destinations. |
|
226 | + if ( stripos( $facet_source, 'destination_to' ) ) { |
|
227 | + $from .= " INNER JOIN {$wpdb->posts} p ON f.facet_value = p.ID"; |
|
228 | + $where .= " AND p.post_parent = '0'"; |
|
229 | + |
|
230 | + } |
|
231 | + |
|
232 | + $response = $wpdb->prepare( "SELECT {$select} FROM {$from} WHERE {$where}" );// WPCS: unprepared SQL OK. |
|
233 | + |
|
234 | + if ( ! empty( $response ) ) { |
|
235 | + foreach ( $response as $re ) { |
|
236 | + $display_value = $re->facet_display_value; |
|
237 | + if ( function_exists( 'pll_translate_string' ) ) { |
|
238 | + $current_lang = pll_current_language(); |
|
239 | + $display_value = pll_translate_string( $display_value, $current_lang ); |
|
240 | + } |
|
241 | + $display_value = apply_filters( 'lsx_search_facetwp_display_value', $display_value, $re->facet_value ); |
|
242 | + $values[ $re->facet_value ] = $display_value; |
|
243 | + } |
|
244 | + } |
|
245 | + |
|
246 | + asort( $values ); |
|
247 | + return $values; |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Change FaceWP pagination HTML to be equal main pagination (WP-PageNavi) |
|
252 | + */ |
|
253 | + public function display_form_field( $type = 'select', $facet = array(), $values = array(), $combo = false ) { |
|
254 | + if ( empty( $facet ) ) { |
|
255 | + return; |
|
256 | + } |
|
257 | + |
|
258 | + $source = 'fwp_' . $facet['name']; |
|
259 | + |
|
260 | + switch ( $type ) { |
|
261 | + |
|
262 | + case 'select': ?> |
|
263 | 263 | <div class="dropdown nav-item <?php if ( true === $combo ) { echo 'combination-dropdown'; } ?>"> |
264 | 264 | <button data-selection="0" class="btn border-btn btn-dropdown dropdown-toggle" type="button" id="<?php echo wp_kses_post( $source ); ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> |
265 | 265 | <?php echo esc_attr( apply_filters( 'lsx_search_facet_label', __( 'Select', 'lsx-search' ) . ' ' . wp_kses_post( $facet['label'] ) ) ); ?> |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | <li style="display: none;"> |
272 | 272 | <a class="default" data-value="0" href="#"> |
273 | 273 | <?php |
274 | - $facet_label = __( 'Select ', 'lsx-search' ) . ' ' . wp_kses_post( $facet['label'] ); |
|
275 | - $facet_label = apply_filters( 'lsx_search_facet_label', $facet_label ); |
|
276 | - echo esc_attr( $facet_label ); |
|
277 | - ?> |
|
274 | + $facet_label = __( 'Select ', 'lsx-search' ) . ' ' . wp_kses_post( $facet['label'] ); |
|
275 | + $facet_label = apply_filters( 'lsx_search_facet_label', $facet_label ); |
|
276 | + echo esc_attr( $facet_label ); |
|
277 | + ?> |
|
278 | 278 | </a> |
279 | 279 | </li> |
280 | 280 | |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | </ul> |
288 | 288 | </div> |
289 | 289 | <?php |
290 | - break; |
|
290 | + break; |
|
291 | 291 | |
292 | - case 'datepicker': ?> |
|
292 | + case 'datepicker': ?> |
|
293 | 293 | <div class="datepicker nav-item"> |
294 | 294 | <input autocomplete="off" class="datepicker-value" placeholder="<?php echo wp_kses_post( apply_filters( 'lsx_search_facet_label' , $facet['label'] ) ); ?>" name="<?php echo wp_kses_post( $source ); ?>" id="<?php echo wp_kses_post( $source ); ?>" type="text" value="" /> |
295 | 295 | </div> |
296 | 296 | <?php |
297 | - break; |
|
298 | - } |
|
297 | + break; |
|
298 | + } |
|
299 | 299 | |
300 | - ?> |
|
300 | + ?> |
|
301 | 301 | |
302 | 302 | <?php } |
303 | 303 | } |
@@ -10,76 +10,76 @@ discard block |
||
10 | 10 | * Construct method. |
11 | 11 | */ |
12 | 12 | public function __construct() { |
13 | - add_shortcode( 'lsx_search_form', array( $this, 'search_form' ) ); |
|
13 | + add_shortcode('lsx_search_form', array($this, 'search_form')); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Outputs the appropriate search form |
18 | 18 | */ |
19 | - public function search_form( $atts = array() ) { |
|
19 | + public function search_form($atts = array()) { |
|
20 | 20 | $classes = 'search-form lsx-search-form form-inline'; |
21 | 21 | |
22 | - if ( isset( $atts['class'] ) ) { |
|
22 | + if (isset($atts['class'])) { |
|
23 | 23 | $classes .= $atts['class']; |
24 | 24 | } |
25 | 25 | |
26 | - $placeholder = __( 'Where do you want to go?', 'lsx-search' ); |
|
26 | + $placeholder = __('Where do you want to go?', 'lsx-search'); |
|
27 | 27 | |
28 | - if ( isset( $atts['placeholder'] ) ) { |
|
28 | + if (isset($atts['placeholder'])) { |
|
29 | 29 | $placeholder = $atts['placeholder']; |
30 | 30 | } |
31 | 31 | |
32 | 32 | $action = '/'; |
33 | 33 | |
34 | - if ( isset( $atts['action'] ) ) { |
|
34 | + if (isset($atts['action'])) { |
|
35 | 35 | $action = $atts['action']; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $method = 'get'; |
39 | 39 | |
40 | - if ( isset( $atts['method'] ) ) { |
|
40 | + if (isset($atts['method'])) { |
|
41 | 41 | $method = $atts['method']; |
42 | 42 | } |
43 | 43 | |
44 | - $button_label = __( 'Search', 'lsx-search' ); |
|
44 | + $button_label = __('Search', 'lsx-search'); |
|
45 | 45 | |
46 | - if ( isset( $atts['button_label'] ) ) { |
|
46 | + if (isset($atts['button_label'])) { |
|
47 | 47 | $button_label = $atts['button_label']; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $button_class = 'btn cta-btn '; |
51 | 51 | |
52 | - if ( isset( $atts['button_class'] ) ) { |
|
52 | + if (isset($atts['button_class'])) { |
|
53 | 53 | $button_class .= $atts['button_class']; |
54 | 54 | } |
55 | 55 | |
56 | 56 | $engine = false; |
57 | 57 | |
58 | - if ( isset( $atts['engine'] ) ) { |
|
58 | + if (isset($atts['engine'])) { |
|
59 | 59 | $engine = $atts['engine']; |
60 | 60 | } |
61 | 61 | |
62 | 62 | $engine_select = false; |
63 | 63 | |
64 | - if ( isset( $atts['engine_select'] ) ) { |
|
64 | + if (isset($atts['engine_select'])) { |
|
65 | 65 | $engine_select = true; |
66 | 66 | } |
67 | 67 | |
68 | 68 | $display_search_field = true; |
69 | 69 | |
70 | - if ( isset( $atts['search_field'] ) ) { |
|
70 | + if (isset($atts['search_field'])) { |
|
71 | 71 | $display_search_field = (boolean) $atts['search_field']; |
72 | 72 | } |
73 | 73 | |
74 | 74 | $facets = false; |
75 | 75 | |
76 | - if ( isset( $atts['facets'] ) ) { |
|
76 | + if (isset($atts['facets'])) { |
|
77 | 77 | $facets = $atts['facets']; |
78 | 78 | } |
79 | 79 | |
80 | 80 | $combo_box = false; |
81 | 81 | |
82 | - if ( isset( $atts['combo_box'] ) ) { |
|
82 | + if (isset($atts['combo_box'])) { |
|
83 | 83 | $combo_box = true; |
84 | 84 | } |
85 | 85 | |
@@ -87,40 +87,40 @@ discard block |
||
87 | 87 | |
88 | 88 | ob_start(); ?> |
89 | 89 | |
90 | - <?php do_action( 'lsx_search_form_before' ); ?> |
|
90 | + <?php do_action('lsx_search_form_before'); ?> |
|
91 | 91 | |
92 | 92 | <nav class="navbar navbar-light bg-light"> |
93 | 93 | |
94 | - <form class="<?php echo esc_attr( $classes ); ?>" action="<?php echo esc_attr( $action ); ?>" method="<?php echo esc_attr( $method ); ?>"> |
|
94 | + <form class="<?php echo esc_attr($classes); ?>" action="<?php echo esc_attr($action); ?>" method="<?php echo esc_attr($method); ?>"> |
|
95 | 95 | |
96 | - <?php do_action( 'lsx_search_form_top' ); ?> |
|
96 | + <?php do_action('lsx_search_form_top'); ?> |
|
97 | 97 | |
98 | 98 | <div class="input-group navbar-nav"> |
99 | - <?php if ( true === $display_search_field ) : ?> |
|
99 | + <?php if (true === $display_search_field) : ?> |
|
100 | 100 | <div class="field"> |
101 | - <input class="search-field form-control" name="s" type="search" placeholder="<?php echo esc_attr( $placeholder ); ?>" autocomplete="off"> |
|
101 | + <input class="search-field form-control" name="s" type="search" placeholder="<?php echo esc_attr($placeholder); ?>" autocomplete="off"> |
|
102 | 102 | </div> |
103 | 103 | <?php endif; ?> |
104 | 104 | |
105 | - <?php if ( false !== $engine_select && false !== $engine && 'default' !== $engine ) : |
|
106 | - $engines = explode( '|',$engine ); ?> |
|
105 | + <?php if (false !== $engine_select && false !== $engine && 'default' !== $engine) : |
|
106 | + $engines = explode('|', $engine); ?> |
|
107 | 107 | <div class="field engine-select"> |
108 | 108 | <div class="dropdown nav-item"> |
109 | 109 | <?php |
110 | 110 | $plural = 's'; |
111 | - if ( 'accommodation' === $engine[0] ) { |
|
111 | + if ('accommodation' === $engine[0]) { |
|
112 | 112 | $plural = ''; |
113 | 113 | } |
114 | 114 | ?> |
115 | - <button id="engine" data-selection="<?php echo esc_attr( $engines[0] ); ?>" class="btn border-btn btn-dropdown dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo esc_html( ucwords( str_replace( '_', ' ',$engines[0] ) ) . $plural ); ?> <span class="caret"></span></button> |
|
115 | + <button id="engine" data-selection="<?php echo esc_attr($engines[0]); ?>" class="btn border-btn btn-dropdown dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><?php echo esc_html(ucwords(str_replace('_', ' ', $engines[0])).$plural); ?> <span class="caret"></span></button> |
|
116 | 116 | <ul class="dropdown-menu"> |
117 | 117 | <?php |
118 | - foreach ( $engines as $engine ) { |
|
118 | + foreach ($engines as $engine) { |
|
119 | 119 | $plural = 's'; |
120 | - if ( 'accommodation' === $engine ) { |
|
120 | + if ('accommodation' === $engine) { |
|
121 | 121 | $plural = ''; |
122 | 122 | } |
123 | - echo '<li><a data-value="' . esc_attr( $engine ) . '" href="#">' . esc_html( ucfirst( str_replace( '_', ' ',$engine ) ) . $plural ) . '</a></li>'; |
|
123 | + echo '<li><a data-value="'.esc_attr($engine).'" href="#">'.esc_html(ucfirst(str_replace('_', ' ', $engine)).$plural).'</a></li>'; |
|
124 | 124 | } |
125 | 125 | ?> |
126 | 126 | </ul> |
@@ -128,32 +128,32 @@ discard block |
||
128 | 128 | </div> |
129 | 129 | <?php endif; ?> |
130 | 130 | |
131 | - <?php if ( false !== $facets ) { |
|
132 | - $facets = explode( '|',$facets ); |
|
131 | + <?php if (false !== $facets) { |
|
132 | + $facets = explode('|', $facets); |
|
133 | 133 | |
134 | - if ( ! is_array( $facets ) ) { |
|
135 | - $facets = array( $facets ); |
|
134 | + if (!is_array($facets)) { |
|
135 | + $facets = array($facets); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | $field_class = 'field'; |
139 | 139 | |
140 | - if ( false !== $combo_box ) { |
|
141 | - $this->combo_box( $facets ); |
|
140 | + if (false !== $combo_box) { |
|
141 | + $this->combo_box($facets); |
|
142 | 142 | $field_class .= ' combination-toggle hidden'; |
143 | 143 | } |
144 | 144 | |
145 | - foreach ( $facets as $facet ) { |
|
145 | + foreach ($facets as $facet) { |
|
146 | 146 | ?> |
147 | - <div class="<?php echo wp_kses_post( $field_class ); ?>"> |
|
147 | + <div class="<?php echo wp_kses_post($field_class); ?>"> |
|
148 | 148 | <?php |
149 | - $facet = FWP()->helper->get_facet_by_name( $facet ); |
|
150 | - if ( isset( $facet['source'] ) ) { |
|
151 | - $values = $this->get_form_facet( $facet['source'] ); |
|
149 | + $facet = FWP()->helper->get_facet_by_name($facet); |
|
150 | + if (isset($facet['source'])) { |
|
151 | + $values = $this->get_form_facet($facet['source']); |
|
152 | 152 | } else { |
153 | 153 | $values = array(); |
154 | 154 | } |
155 | - $facet_display_type = apply_filters( 'lsx_search_form_field_type', 'select', $facet ); |
|
156 | - $this->display_form_field( $facet_display_type,$facet,$values,$combo_box ); |
|
155 | + $facet_display_type = apply_filters('lsx_search_form_field_type', 'select', $facet); |
|
156 | + $this->display_form_field($facet_display_type, $facet, $values, $combo_box); |
|
157 | 157 | ?> |
158 | 158 | </div> |
159 | 159 | <?php |
@@ -161,26 +161,26 @@ discard block |
||
161 | 161 | } ?> |
162 | 162 | |
163 | 163 | <div class="field submit-button"> |
164 | - <button class="<?php echo esc_attr( $button_class ); ?>" type="submit"><?php echo wp_kses_post( $button_label ); ?></button> |
|
164 | + <button class="<?php echo esc_attr($button_class); ?>" type="submit"><?php echo wp_kses_post($button_label); ?></button> |
|
165 | 165 | </div> |
166 | 166 | |
167 | - <?php if ( false === $engine_select && false !== $engine && 'default' !== $engine ) : ?> |
|
168 | - <input name="engine" type="hidden" value="<?php echo esc_attr( $engine ); ?>"> |
|
167 | + <?php if (false === $engine_select && false !== $engine && 'default' !== $engine) : ?> |
|
168 | + <input name="engine" type="hidden" value="<?php echo esc_attr($engine); ?>"> |
|
169 | 169 | <?php endif; ?> |
170 | 170 | </div> |
171 | 171 | |
172 | - <?php do_action( 'lsx_search_form_bottom' ); ?> |
|
172 | + <?php do_action('lsx_search_form_bottom'); ?> |
|
173 | 173 | |
174 | 174 | </form> |
175 | 175 | |
176 | 176 | </nav> |
177 | 177 | |
178 | - <?php do_action( 'lsx_search_form_after' ); ?> |
|
178 | + <?php do_action('lsx_search_form_after'); ?> |
|
179 | 179 | <?php |
180 | 180 | $return = ob_get_clean(); |
181 | 181 | |
182 | - $return = preg_replace( '/[\n]+/', ' ', $return ); |
|
183 | - $return = preg_replace( '/[\t]+/', ' ', $return ); |
|
182 | + $return = preg_replace('/[\n]+/', ' ', $return); |
|
183 | + $return = preg_replace('/[\t]+/', ' ', $return); |
|
184 | 184 | |
185 | 185 | return $return; |
186 | 186 | } |
@@ -188,22 +188,22 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * Outputs the combination selector |
190 | 190 | */ |
191 | - public function combo_box( $facets ) { |
|
191 | + public function combo_box($facets) { |
|
192 | 192 | ?> |
193 | 193 | <div class="field combination-dropdown"> |
194 | 194 | <div class="dropdown"> |
195 | 195 | <button data-selection="0" class="btn border-btn btn-dropdown dropdown-toggle btn-combination" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> |
196 | - <?php esc_attr_e( 'Select', 'lsx-search' ); ?> |
|
196 | + <?php esc_attr_e('Select', 'lsx-search'); ?> |
|
197 | 197 | <span class="caret"></span> |
198 | 198 | </button> |
199 | 199 | <ul class="dropdown-menu"> |
200 | 200 | |
201 | - <li style="display: none;"><a class="default" data-value="0" href="#"><?php esc_attr_e( 'Select ', 'lsx-search' ); ?></a></li> |
|
201 | + <li style="display: none;"><a class="default" data-value="0" href="#"><?php esc_attr_e('Select ', 'lsx-search'); ?></a></li> |
|
202 | 202 | |
203 | - <?php foreach ( $facets as $facet ) { |
|
204 | - $facet = FWP()->helper->get_facet_by_name( $facet ); |
|
203 | + <?php foreach ($facets as $facet) { |
|
204 | + $facet = FWP()->helper->get_facet_by_name($facet); |
|
205 | 205 | ?> |
206 | - <li><a data-value="fwp_<?php echo wp_kses_post( $facet['name'] ); ?>" href="#"><?php echo wp_kses_post( $facet['label'] ); ?></a></li> |
|
206 | + <li><a data-value="fwp_<?php echo wp_kses_post($facet['name']); ?>" href="#"><?php echo wp_kses_post($facet['label']); ?></a></li> |
|
207 | 207 | <?php } ?> |
208 | 208 | </ul> |
209 | 209 | </div> |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | /** |
215 | 215 | * Grabs the Values for the Facet in Question. |
216 | 216 | */ |
217 | - protected function get_form_facet( $facet_source = false ) { |
|
217 | + protected function get_form_facet($facet_source = false) { |
|
218 | 218 | global $wpdb; |
219 | 219 | |
220 | 220 | $values = array(); |
@@ -223,66 +223,66 @@ discard block |
||
223 | 223 | $where = "f.facet_source = '{$facet_source}'"; |
224 | 224 | |
225 | 225 | //Check if the current facet is showing destinations. |
226 | - if ( stripos( $facet_source, 'destination_to' ) ) { |
|
226 | + if (stripos($facet_source, 'destination_to')) { |
|
227 | 227 | $from .= " INNER JOIN {$wpdb->posts} p ON f.facet_value = p.ID"; |
228 | 228 | $where .= " AND p.post_parent = '0'"; |
229 | 229 | |
230 | 230 | } |
231 | 231 | |
232 | - $response = $wpdb->prepare( "SELECT {$select} FROM {$from} WHERE {$where}" );// WPCS: unprepared SQL OK. |
|
232 | + $response = $wpdb->prepare("SELECT {$select} FROM {$from} WHERE {$where}"); // WPCS: unprepared SQL OK. |
|
233 | 233 | |
234 | - if ( ! empty( $response ) ) { |
|
235 | - foreach ( $response as $re ) { |
|
234 | + if (!empty($response)) { |
|
235 | + foreach ($response as $re) { |
|
236 | 236 | $display_value = $re->facet_display_value; |
237 | - if ( function_exists( 'pll_translate_string' ) ) { |
|
237 | + if (function_exists('pll_translate_string')) { |
|
238 | 238 | $current_lang = pll_current_language(); |
239 | - $display_value = pll_translate_string( $display_value, $current_lang ); |
|
239 | + $display_value = pll_translate_string($display_value, $current_lang); |
|
240 | 240 | } |
241 | - $display_value = apply_filters( 'lsx_search_facetwp_display_value', $display_value, $re->facet_value ); |
|
242 | - $values[ $re->facet_value ] = $display_value; |
|
241 | + $display_value = apply_filters('lsx_search_facetwp_display_value', $display_value, $re->facet_value); |
|
242 | + $values[$re->facet_value] = $display_value; |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | - asort( $values ); |
|
246 | + asort($values); |
|
247 | 247 | return $values; |
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Change FaceWP pagination HTML to be equal main pagination (WP-PageNavi) |
252 | 252 | */ |
253 | - public function display_form_field( $type = 'select', $facet = array(), $values = array(), $combo = false ) { |
|
254 | - if ( empty( $facet ) ) { |
|
253 | + public function display_form_field($type = 'select', $facet = array(), $values = array(), $combo = false) { |
|
254 | + if (empty($facet)) { |
|
255 | 255 | return; |
256 | 256 | } |
257 | 257 | |
258 | - $source = 'fwp_' . $facet['name']; |
|
258 | + $source = 'fwp_'.$facet['name']; |
|
259 | 259 | |
260 | - switch ( $type ) { |
|
260 | + switch ($type) { |
|
261 | 261 | |
262 | 262 | case 'select': ?> |
263 | - <div class="dropdown nav-item <?php if ( true === $combo ) { echo 'combination-dropdown'; } ?>"> |
|
264 | - <button data-selection="0" class="btn border-btn btn-dropdown dropdown-toggle" type="button" id="<?php echo wp_kses_post( $source ); ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> |
|
265 | - <?php echo esc_attr( apply_filters( 'lsx_search_facet_label', __( 'Select', 'lsx-search' ) . ' ' . wp_kses_post( $facet['label'] ) ) ); ?> |
|
263 | + <div class="dropdown nav-item <?php if (true === $combo) { echo 'combination-dropdown'; } ?>"> |
|
264 | + <button data-selection="0" class="btn border-btn btn-dropdown dropdown-toggle" type="button" id="<?php echo wp_kses_post($source); ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> |
|
265 | + <?php echo esc_attr(apply_filters('lsx_search_facet_label', __('Select', 'lsx-search').' '.wp_kses_post($facet['label']))); ?> |
|
266 | 266 | <span class="caret"></span> |
267 | 267 | </button> |
268 | - <ul class="dropdown-menu" aria-labelledby="<?php echo wp_kses_post( $source ); ?>"> |
|
269 | - <?php if ( ! empty( $values ) ) { ?> |
|
268 | + <ul class="dropdown-menu" aria-labelledby="<?php echo wp_kses_post($source); ?>"> |
|
269 | + <?php if (!empty($values)) { ?> |
|
270 | 270 | |
271 | 271 | <li style="display: none;"> |
272 | 272 | <a class="default" data-value="0" href="#"> |
273 | 273 | <?php |
274 | - $facet_label = __( 'Select ', 'lsx-search' ) . ' ' . wp_kses_post( $facet['label'] ); |
|
275 | - $facet_label = apply_filters( 'lsx_search_facet_label', $facet_label ); |
|
276 | - echo esc_attr( $facet_label ); |
|
274 | + $facet_label = __('Select ', 'lsx-search').' '.wp_kses_post($facet['label']); |
|
275 | + $facet_label = apply_filters('lsx_search_facet_label', $facet_label); |
|
276 | + echo esc_attr($facet_label); |
|
277 | 277 | ?> |
278 | 278 | </a> |
279 | 279 | </li> |
280 | 280 | |
281 | - <?php foreach ( $values as $key => $value ) { ?> |
|
282 | - <li><a data-value="<?php echo wp_kses_post( $key ); ?>" href="#"><?php echo wp_kses_post( $value ); ?></a></li> |
|
281 | + <?php foreach ($values as $key => $value) { ?> |
|
282 | + <li><a data-value="<?php echo wp_kses_post($key); ?>" href="#"><?php echo wp_kses_post($value); ?></a></li> |
|
283 | 283 | <?php } ?> |
284 | 284 | <?php } else { ?> |
285 | - <li><a data-value="0" href="#"><?php esc_attr_e( 'Please re-index your facets.', 'lsx-search' ); ?></a></li> |
|
285 | + <li><a data-value="0" href="#"><?php esc_attr_e('Please re-index your facets.', 'lsx-search'); ?></a></li> |
|
286 | 286 | <?php } ?> |
287 | 287 | </ul> |
288 | 288 | </div> |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | |
292 | 292 | case 'datepicker': ?> |
293 | 293 | <div class="datepicker nav-item"> |
294 | - <input autocomplete="off" class="datepicker-value" placeholder="<?php echo wp_kses_post( apply_filters( 'lsx_search_facet_label' , $facet['label'] ) ); ?>" name="<?php echo wp_kses_post( $source ); ?>" id="<?php echo wp_kses_post( $source ); ?>" type="text" value="" /> |
|
294 | + <input autocomplete="off" class="datepicker-value" placeholder="<?php echo wp_kses_post(apply_filters('lsx_search_facet_label', $facet['label'])); ?>" name="<?php echo wp_kses_post($source); ?>" id="<?php echo wp_kses_post($source); ?>" type="text" value="" /> |
|
295 | 295 | </div> |
296 | 296 | <?php |
297 | 297 | break; |
@@ -989,8 +989,11 @@ |
||
989 | 989 | |
990 | 990 | if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?> |
991 | 991 | <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
992 | - <?php else : ?> |
|
993 | - <div class="col-xs-12 facetwp-item parent-facetwp-facet-<?php echo esc_html( $facet ); ?> <?php echo esc_attr( $col_class ); ?>"> |
|
992 | + <?php else { |
|
993 | + : ?> |
|
994 | + <div class="col-xs-12 facetwp-item parent-facetwp-facet-<?php echo esc_html( $facet ); |
|
995 | +} |
|
996 | +?> <?php echo esc_attr( $col_class ); ?>"> |
|
994 | 997 | <?php if ( ! $show_collapse ) { ?> |
995 | 998 | <div class="facetwp-collapsed"> |
996 | 999 | <h3 class="lsx-search-title"><?php echo wp_kses_post( $this->facet_data[ $facet ]['label'] ); ?></h3> |
@@ -9,686 +9,686 @@ discard block |
||
9 | 9 | |
10 | 10 | class Frontend { |
11 | 11 | |
12 | - /** |
|
13 | - * Holds class instance |
|
14 | - * |
|
15 | - * @since 1.0.0 |
|
16 | - * |
|
17 | - * @var object \lsx\search\classes\Frontend() |
|
18 | - */ |
|
19 | - protected static $instance = null; |
|
20 | - |
|
21 | - public $options = false; |
|
22 | - |
|
23 | - public $tabs = false; |
|
24 | - |
|
25 | - public $facet_data = false; |
|
26 | - |
|
27 | - /** |
|
28 | - * Determine weather or not search is enabled for this page. |
|
29 | - * |
|
30 | - * @var boolean |
|
31 | - */ |
|
32 | - public $search_enabled = false; |
|
33 | - |
|
34 | - public $search_core_suffix = false; |
|
35 | - |
|
36 | - public $search_prefix = false; |
|
37 | - |
|
38 | - /** |
|
39 | - * Holds the post types enabled |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - public $post_types = array(); |
|
44 | - |
|
45 | - /** |
|
46 | - * Holds the taxonomies enabled for search |
|
47 | - * |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - public $taxonomies = array(); |
|
51 | - |
|
52 | - /** |
|
53 | - * If the current search page has posts or not |
|
54 | - * |
|
55 | - * @var boolean |
|
56 | - */ |
|
57 | - public $has_posts = false; |
|
58 | - |
|
59 | - /** |
|
60 | - * If we are using the CMB2 options or not. |
|
61 | - * |
|
62 | - * @var boolean |
|
63 | - */ |
|
64 | - public $new_options = false; |
|
65 | - |
|
66 | - /** |
|
67 | - * Construct method. |
|
68 | - */ |
|
69 | - public function __construct() { |
|
70 | - $this->options = \lsx\search\includes\get_options(); |
|
71 | - $this->load_classes(); |
|
72 | - |
|
73 | - add_filter( 'wpseo_json_ld_search_url', array( $this, 'change_json_ld_search_url' ), 10, 1 ); |
|
74 | - add_action( 'wp', array( $this, 'set_vars' ), 21 ); |
|
75 | - add_action( 'wp', array( $this, 'set_facetwp_vars' ), 22 ); |
|
76 | - add_action( 'wp', array( $this, 'core' ), 23 ); |
|
77 | - add_action( 'lsx_body_top', array( $this, 'check_for_results' ) ); |
|
78 | - |
|
79 | - add_filter( 'pre_get_posts', array( $this, 'ignore_sticky_search' ) ); |
|
80 | - add_action( 'pre_get_posts', array( $this, 'filter_post_types' ) ); |
|
81 | - |
|
82 | - add_filter( 'lsx_search_post_types', array( $this, 'register_post_types' ) ); |
|
83 | - add_filter( 'lsx_search_taxonomies', array( $this, 'register_taxonomies' ) ); |
|
84 | - add_filter( 'lsx_search_post_types_plural', array( $this, 'register_post_type_tabs' ) ); |
|
85 | - add_filter( 'facetwp_sort_options', array( $this, 'facetwp_sort_options' ), 10, 2 ); |
|
86 | - add_filter( 'wp_kses_allowed_html', array( $this, 'kses_allowed_html' ), 20, 2 ); |
|
87 | - add_filter( 'get_search_query', array( $this, 'get_search_query' ) ); |
|
88 | - |
|
89 | - // Redirects. |
|
90 | - add_action( 'template_redirect', array( $this, 'pretty_search_redirect' ) ); |
|
91 | - add_filter( 'pre_get_posts', array( $this, 'pretty_search_parse_query' ) ); |
|
92 | - |
|
93 | - add_action( 'lsx_search_sidebar_top', array( $this, 'search_sidebar_top' ) ); |
|
94 | - add_filter( 'facetwp_facet_html', array( $this, 'search_facet_html' ), 10, 2 ); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Return an instance of this class. |
|
99 | - * |
|
100 | - * @since 1.0.0 |
|
101 | - * |
|
102 | - * @return object \lsx\member_directory\search\Frontend() A single instance of this class. |
|
103 | - */ |
|
104 | - public static function get_instance() { |
|
105 | - // If the single instance hasn't been set, set it now. |
|
106 | - if ( null === self::$instance ) { |
|
107 | - self::$instance = new self(); |
|
108 | - } |
|
109 | - return self::$instance; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Loads the variable classes and the static classes. |
|
114 | - */ |
|
115 | - private function load_classes() { |
|
116 | - require_once LSX_SEARCH_PATH . 'classes/frontend/class-layout.php'; |
|
117 | - $this->layout = frontend\Layout::get_instance(); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Check all settings. |
|
122 | - */ |
|
123 | - public function set_vars() { |
|
124 | - $post_type = ''; |
|
125 | - |
|
126 | - $this->post_types = apply_filters( 'lsx_search_post_types', array() ); |
|
127 | - $this->taxonomies = apply_filters( 'lsx_search_taxonomies', array() ); |
|
128 | - $this->tabs = apply_filters( 'lsx_search_post_types_plural', array() ); |
|
129 | - $this->options = apply_filters( 'lsx_search_options', $this->options ); |
|
130 | - $this->post_types = get_post_types(); |
|
131 | - $this->post_type_slugs = array( |
|
132 | - 'post' => 'posts', |
|
133 | - 'project' => 'projects', |
|
134 | - 'service' => 'services', |
|
135 | - 'team' => 'team', |
|
136 | - 'testimonial' => 'testimonials', |
|
137 | - 'video' => 'videos', |
|
138 | - 'product' => 'products', |
|
139 | - ); |
|
140 | - $this->set_search_prefix(); |
|
141 | - $this->get_cmb2_options(); |
|
142 | - $this->search_enabled = apply_filters( 'lsx_search_enabled', $this->is_search_enabled(), $this ); |
|
143 | - $this->search_prefix = apply_filters( 'lsx_search_prefix', $this->search_prefix, $this ); |
|
144 | - } |
|
145 | - |
|
146 | - private function get_cmb2_options() { |
|
147 | - $cmb2_options = get_option( 'lsx-search-settings' ); |
|
148 | - if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
149 | - $this->set_search_prefix( true ); |
|
150 | - $this->options['display'] = $cmb2_options; |
|
151 | - foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
152 | - if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
153 | - $new_values = array(); |
|
154 | - foreach ( $option_value as $empty_key => $key_value ) { |
|
155 | - $new_values[ $key_value ] = 'on'; |
|
156 | - } |
|
157 | - $this->options['display'][ $option_key ] = $new_values; |
|
158 | - } |
|
159 | - } |
|
160 | - $this->new_options = true; |
|
161 | - $this->disable_to_search_actions(); |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - private function disable_to_search_actions() { |
|
166 | - global $lsx_to_search_fwp, $lsx_to_search; |
|
167 | - if ( null !== $lsx_to_search ) { |
|
168 | - // Redirects. |
|
169 | - remove_filter( 'template_include', array( $lsx_to_search, 'search_template_include' ), 99 ); |
|
170 | - remove_action( 'template_redirect', array( $lsx_to_search, 'pretty_search_redirect' ) ); |
|
171 | - remove_filter( 'pre_get_posts', array( $lsx_to_search, 'pretty_search_parse_query' ) ); |
|
172 | - |
|
173 | - // Layout Filter. |
|
174 | - remove_filter( 'lsx_layout', array( $lsx_to_search, 'lsx_layout' ), 20, 1 ); |
|
175 | - remove_filter( 'lsx_layout_selector', array( $lsx_to_search, 'lsx_layout_selector' ), 10, 4 ); |
|
176 | - remove_filter( 'lsx_to_archive_layout', array( $lsx_to_search, 'lsx_to_search_archive_layout' ), 10, 2 ); |
|
177 | - |
|
178 | - remove_action( 'lsx_search_sidebar_top', array( $lsx_to_search, 'search_sidebar_top' ) ); |
|
179 | - remove_action( 'pre_get_posts', array( $lsx_to_search, 'price_sorting' ), 100 ); |
|
180 | - |
|
181 | - //add_shortcode( 'lsx_search_form', array( 'LSX_TO_Search_Frontend', 'search_form' ) ); |
|
182 | - remove_filter( 'searchwp_short_circuit', array( $lsx_to_search, 'searchwp_short_circuit' ), 10, 2 ); |
|
183 | - remove_filter( 'get_search_query', array( $lsx_to_search, 'get_search_query' ) ); |
|
184 | - remove_filter( 'body_class', array( $lsx_to_search, 'to_add_search_url_class' ), 20 ); |
|
185 | - |
|
186 | - remove_filter( 'facetwp_preload_url_vars', array( $lsx_to_search, 'preload_url_vars' ), 10, 1 ); |
|
187 | - remove_filter( 'wpseo_json_ld_search_url', array( $lsx_to_search, 'change_json_ld_search_url' ), 10, 1 ); |
|
188 | - } |
|
189 | - if ( null !== $lsx_to_search_fwp ) { |
|
190 | - remove_filter( 'facetwp_indexer_row_data', array( $lsx_to_search_fwp, 'facetwp_index_row_data' ), 10, 2 ); |
|
191 | - remove_filter( 'facetwp_index_row', array( $lsx_to_search_fwp, 'facetwp_index_row' ), 10, 2 ); |
|
192 | - |
|
193 | - remove_filter( 'facetwp_sort_options', array( $lsx_to_search_fwp, 'facet_sort_options' ), 10, 2 ); |
|
194 | - |
|
195 | - remove_filter( 'facetwp_pager_html', array( $lsx_to_search_fwp, 'facetwp_pager_html' ), 10, 2 ); |
|
196 | - remove_filter( 'facetwp_result_count', array( $lsx_to_search_fwp, 'facetwp_result_count' ), 10, 2 ); |
|
197 | - |
|
198 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'destination_facet_html' ), 10, 2 ); |
|
199 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'slide_facet_html' ), 10, 2 ); |
|
200 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'search_facet_html' ), 10, 2 ); |
|
201 | - remove_filter( 'facetwp_load_css', array( $lsx_to_search_fwp, 'facetwp_load_css' ), 10, 1 ); |
|
202 | - |
|
203 | - if ( class_exists( 'LSX_Currencies' ) ) { |
|
204 | - remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_lsx_currencies' ), 10, 2 ); |
|
205 | - } else { |
|
206 | - remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_to_currencies' ), 10, 2 ); |
|
207 | - } |
|
208 | - } |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * Returns if the search is enabled. |
|
213 | - * |
|
214 | - * @return boolean |
|
215 | - */ |
|
216 | - public function is_search_enabled() { |
|
217 | - $search_enabled = false; |
|
218 | - |
|
219 | - if ( false === $this->new_options ) { |
|
220 | - if ( isset( $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) && ( ! empty( $this->options ) ) && 'on' == $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) { |
|
221 | - $search_enabled = true; |
|
222 | - } |
|
223 | - } else { |
|
224 | - $enable_prefix = $this->search_prefix; |
|
225 | - if ( ! empty( $this->options ) && isset( $this->options['display'] ) && isset( $this->options['display'][ $enable_prefix . '_enable' ] ) && 'on' === $this->options['display'][ $enable_prefix . '_enable' ] ) { |
|
226 | - $search_enabled = true; |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - // These are specific plugin exclusions. |
|
231 | - if ( is_tax( array( 'wcpv_product_vendors' ) ) ) { |
|
232 | - $search_enabled = false; |
|
233 | - } |
|
234 | - return $search_enabled; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * Sets the search prefix. |
|
239 | - * |
|
240 | - * @return void |
|
241 | - */ |
|
242 | - private function set_search_prefix( $new_prefixes = false ) { |
|
243 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
244 | - if ( false !== $new_prefixes ) { |
|
245 | - $this->taxonomies = array(); |
|
246 | - $this->post_types = array(); |
|
247 | - } |
|
248 | - |
|
249 | - if ( is_search() ) { |
|
250 | - if ( false === $new_prefixes ) { |
|
251 | - $this->search_core_suffix = 'core'; |
|
252 | - $this->search_prefix = 'search'; |
|
253 | - } else { |
|
254 | - $this->search_core_suffix = 'enable'; |
|
255 | - $this->search_prefix = 'engine_search'; |
|
256 | - } |
|
257 | - } elseif ( is_post_type_archive( $this->post_types ) || is_tax() || is_page( $page_for_posts ) || is_home() || is_category() || is_tag() ) { |
|
258 | - if ( false === $new_prefixes ) { |
|
259 | - $this->search_core_suffix = 'search'; |
|
260 | - } else { |
|
261 | - $this->search_core_suffix = 'enable'; |
|
262 | - } |
|
263 | - |
|
264 | - if ( is_tax() ) { |
|
265 | - $tax = get_query_var( 'taxonomy' ); |
|
266 | - $tax = get_taxonomy( $tax ); |
|
267 | - $post_type = $tax->object_type[0]; |
|
268 | - } else if ( is_page( $page_for_posts ) || is_category() || is_tag() || is_home() ) { |
|
269 | - $post_type = 'post'; |
|
270 | - } else { |
|
271 | - $post_type = get_query_var( 'post_type' ); |
|
272 | - } |
|
273 | - |
|
274 | - if ( false === $new_prefixes ) { |
|
275 | - if ( isset( $this->tabs[ $post_type ] ) ) { |
|
276 | - $this->search_prefix = $this->tabs[ $post_type ] . '_archive'; |
|
277 | - } |
|
278 | - } else { |
|
279 | - $this->search_prefix = $post_type . '_search'; |
|
280 | - } |
|
281 | - } |
|
282 | - } |
|
283 | - |
|
284 | - /** |
|
285 | - * Sets the FacetWP variables. |
|
286 | - */ |
|
287 | - public function set_facetwp_vars() { |
|
288 | - |
|
289 | - if ( class_exists( 'FacetWP' ) ) { |
|
290 | - $facet_data = FWP()->helper->get_facets(); |
|
291 | - } |
|
292 | - |
|
293 | - $this->facet_data = array(); |
|
294 | - |
|
295 | - $this->facet_data['search_form'] = array( |
|
296 | - 'name' => 'search_form', |
|
297 | - 'label' => esc_html__( 'Search Form', 'lsx-search' ), |
|
298 | - ); |
|
299 | - |
|
300 | - if ( ! empty( $facet_data ) && is_array( $facet_data ) ) { |
|
301 | - foreach ( $facet_data as $facet ) { |
|
302 | - $this->facet_data[ $facet['name'] ] = $facet; |
|
303 | - } |
|
304 | - } |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * Check all settings. |
|
309 | - */ |
|
310 | - public function core() { |
|
311 | - |
|
312 | - if ( true === $this->search_enabled ) { |
|
313 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 999 ); |
|
314 | - |
|
315 | - add_filter( 'lsx_layout', array( $this, 'lsx_layout' ), 20, 1 ); |
|
316 | - add_filter( 'lsx_layout_selector', array( $this, 'lsx_layout_selector' ), 10, 4 ); |
|
317 | - add_filter( 'lsx_slot_class', array( $this, 'change_slot_column_class' ) ); |
|
318 | - add_action( 'lsx_entry_top', array( $this, 'add_label_to_title' ) ); |
|
319 | - add_filter( 'body_class', array( $this, 'body_class' ), 10 ); |
|
320 | - |
|
321 | - add_filter( 'lsx_blog_customizer_top_of_blog_action', array( $this, 'top_of_blog_action' ), 10, 1 ); |
|
322 | - add_filter( 'lsx_blog_customizer_blog_description_class', array( $this, 'blog_description_class' ), 10, 1 ); |
|
323 | - |
|
324 | - if ( class_exists( 'LSX_Videos' ) ) { |
|
325 | - global $lsx_videos_frontend; |
|
326 | - remove_action( 'lsx_content_top', array( $lsx_videos_frontend, 'categories_tabs' ), 15 ); |
|
327 | - } |
|
328 | - |
|
329 | - add_filter( 'lsx_paging_nav_disable', '__return_true' ); |
|
330 | - add_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
331 | - add_action( 'lsx_content_top', array( $this, 'facetwp_tempate_open' ) ); |
|
332 | - add_action( 'lsx_content_bottom', array( $this, 'facetwp_tempate_close' ) ); |
|
333 | - add_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
334 | - |
|
335 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) && '1c' !== $this->options['display'][ $this->search_prefix . '_layout' ] ) { |
|
336 | - add_filter( 'lsx_sidebar_enable', array( $this, 'lsx_sidebar_enable' ), 10, 1 ); |
|
337 | - } |
|
338 | - |
|
339 | - add_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
340 | - |
|
341 | - if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) { |
|
342 | - remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' ); |
|
343 | - remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' ); |
|
344 | - add_filter( 'woocommerce_show_page_title', '__return_false' ); |
|
345 | - |
|
346 | - add_filter( 'loop_shop_columns', function() { |
|
347 | - return 3; |
|
348 | - } ); |
|
349 | - |
|
350 | - // Actions added by LSX theme |
|
351 | - remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
|
352 | - add_action( 'lsx_content_wrap_before', array( $this, 'wc_archive_header' ), 140 ); |
|
353 | - |
|
354 | - // Actions added be LSX theme / woocommerce.php file |
|
355 | - remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
356 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
357 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 ); |
|
358 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 ); |
|
359 | - remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
360 | - |
|
361 | - // Actions added be LSX theme / woocommerce.php file |
|
362 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
363 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
364 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
365 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 ); |
|
366 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
367 | - } |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Adds a search class to the body to allow the styling of the sidebars etc. |
|
373 | - * |
|
374 | - * @param array $classes The classes. |
|
375 | - * @return array $classes The classes. |
|
376 | - */ |
|
377 | - public function body_class( $classes ) { |
|
378 | - $classes[] = 'lsx-search-enabled'; |
|
379 | - return $classes; |
|
380 | - } |
|
381 | - |
|
382 | - /** |
|
383 | - * Moves the blog description to above the content columns. |
|
384 | - * |
|
385 | - * @param string $action |
|
386 | - * @return string $action |
|
387 | - */ |
|
388 | - public function top_of_blog_action( $action = '' ) { |
|
389 | - $action = 'lsx_content_wrap_before'; |
|
390 | - return $action; |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Adds a class to the blog description. |
|
395 | - * |
|
396 | - * @param string $action |
|
397 | - * @return string $action |
|
398 | - */ |
|
399 | - public function blog_description_class( $class = '' ) { |
|
400 | - $class .= ' col-md-12 search-description'; |
|
401 | - return $class; |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * Check the $wp_query global to see if there are posts in the current query. |
|
406 | - * |
|
407 | - * @return void |
|
408 | - */ |
|
409 | - public function check_for_results() { |
|
410 | - if ( true === $this->search_enabled ) { |
|
411 | - global $wp_query; |
|
412 | - if ( empty( $wp_query->posts ) ) { |
|
413 | - $this->has_posts = false; |
|
414 | - remove_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
415 | - remove_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
416 | - remove_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
417 | - } else { |
|
418 | - $this->has_posts = true; |
|
419 | - } |
|
420 | - } |
|
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Filter the post types. |
|
425 | - */ |
|
426 | - public function filter_post_types( $query ) { |
|
427 | - if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { |
|
428 | - if ( ! empty( $this->options ) && ! empty( $this->options['display']['search_enable_core'] ) ) { |
|
429 | - if ( ! empty( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
430 | - $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
431 | - $query->set( 'post_type', $post_types ); |
|
432 | - } |
|
433 | - } |
|
434 | - } |
|
435 | - } |
|
436 | - |
|
437 | - /** |
|
438 | - * Sets post types with active search options. |
|
439 | - */ |
|
440 | - public function register_post_types( $post_types ) { |
|
441 | - $post_types = array( 'post', 'project', 'service', 'team', 'testimonial', 'video', 'product' ); |
|
442 | - return $post_types; |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * Sets taxonomies with active search options. |
|
447 | - */ |
|
448 | - public function register_taxonomies( $taxonomies ) { |
|
449 | - $taxonomies = array( 'category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag' ); |
|
450 | - return $taxonomies; |
|
451 | - } |
|
452 | - |
|
453 | - /** |
|
454 | - * Sets post types with active search options. |
|
455 | - */ |
|
456 | - public function register_post_type_tabs( $post_types_plural ) { |
|
457 | - $post_types_plural = array( |
|
458 | - 'post' => 'posts', |
|
459 | - 'project' => 'projects', |
|
460 | - 'service' => 'services', |
|
461 | - 'team' => 'team', |
|
462 | - 'testimonial' => 'testimonials', |
|
463 | - 'video' => 'videos', |
|
464 | - 'product' => 'products', // WooCommerce |
|
465 | - ); |
|
466 | - return $post_types_plural; |
|
467 | - } |
|
468 | - |
|
469 | - /** |
|
470 | - * Enqueue styles and scripts. |
|
471 | - */ |
|
472 | - public function assets() { |
|
473 | - add_filter( 'lsx_defer_parsing_of_js', array( $this, 'skip_js_defer' ), 10, 4 ); |
|
474 | - wp_enqueue_script( 'touchSwipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.touchSwipe.min.js', array( 'jquery' ), LSX_SEARCH_VER, true ); |
|
475 | - wp_enqueue_script( 'slideandswipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.slideandswipe.min.js', array( 'jquery', 'touchSwipe' ), LSX_SEARCH_VER, true ); |
|
476 | - wp_enqueue_script( 'lsx-search', LSX_SEARCH_URL . 'assets/js/src/lsx-search.js', array( 'jquery', 'touchSwipe', 'slideandswipe', 'jquery-ui-datepicker' ), LSX_SEARCH_VER, true ); |
|
477 | - |
|
478 | - $params = apply_filters( 'lsx_search_js_params', array( |
|
479 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
480 | - )); |
|
481 | - |
|
482 | - wp_localize_script( 'lsx-search', 'lsx_customizer_params', $params ); |
|
483 | - |
|
484 | - wp_enqueue_style( 'lsx-search', LSX_SEARCH_URL . 'assets/css/lsx-search.css', array(), LSX_SEARCH_VER ); |
|
485 | - wp_style_add_data( 'lsx-search', 'rtl', 'replace' ); |
|
486 | - |
|
487 | - if ( true === $this->new_options ) { |
|
488 | - wp_deregister_style( 'lsx_to_search' ); |
|
489 | - wp_deregister_script( 'lsx_to_search' ); |
|
490 | - } |
|
491 | - } |
|
492 | - |
|
493 | - /** |
|
494 | - * Adds the to-search.min.js and the to-search.js |
|
495 | - * |
|
496 | - * @param boolean $should_skip |
|
497 | - * @param string $tag |
|
498 | - * @param string $handle |
|
499 | - * @param string $href |
|
500 | - * @return boolean |
|
501 | - */ |
|
502 | - public function skip_js_defer( $should_skip, $tag, $handle, $href ) { |
|
503 | - if ( ! is_admin() && ( false !== stripos( $href, 'lsx-search.min.js' ) || false !== stripos( $href, 'lsx-search.js' ) ) ) { |
|
504 | - $should_skip = true; |
|
505 | - } |
|
506 | - return $should_skip; |
|
507 | - } |
|
508 | - |
|
509 | - /** |
|
510 | - * Redirect wordpress to the search template located in the plugin |
|
511 | - * |
|
512 | - * @param $template |
|
513 | - * @return $template |
|
514 | - */ |
|
515 | - public function search_template_include( $template ) { |
|
516 | - if ( is_main_query() && is_search() ) { |
|
517 | - if ( file_exists( LSX_SEARCH_PATH . 'templates/search.php' ) ) { |
|
518 | - $template = LSX_SEARCH_PATH . 'templates/search.php'; |
|
519 | - } |
|
520 | - } |
|
521 | - |
|
522 | - return $template; |
|
523 | - } |
|
524 | - |
|
525 | - /** |
|
526 | - * Ignore sticky posts on Blog search. |
|
527 | - * |
|
528 | - * @param [type] $query |
|
529 | - * @return void |
|
530 | - */ |
|
531 | - public function ignore_sticky_search( $query ) { |
|
532 | - if ( $query->is_main_query() && is_home() ) { |
|
533 | - $query->set( 'ignore_sticky_posts', true ); |
|
534 | - } |
|
535 | - } |
|
536 | - |
|
537 | - /** |
|
538 | - * Rewrite the search URL |
|
539 | - */ |
|
540 | - public function pretty_search_redirect() { |
|
541 | - global $wp_rewrite,$wp_query; |
|
542 | - |
|
543 | - if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
544 | - return; |
|
545 | - } |
|
546 | - |
|
547 | - $search_base = $wp_rewrite->search_base; |
|
548 | - |
|
549 | - if ( is_search() && ! is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { |
|
550 | - $search_query = get_query_var( 's' ); |
|
551 | - if ( empty( $search_query ) && isset( $_GET['s'] ) ) { |
|
552 | - $search_query = $_GET['s']; |
|
553 | - } |
|
554 | - $engine = ''; |
|
555 | - |
|
556 | - // If the search was triggered by a supplemental engine. |
|
557 | - if ( isset( $_GET['engine'] ) && 'default' !== $_GET['engine'] ) { |
|
558 | - $engine = sanitize_text_field( wp_unslash( $_GET['engine'] ) ); |
|
559 | - $index = array_search( $engine, $this->post_type_slugs, true ); |
|
560 | - if ( false !== $index ) { |
|
561 | - $engine = $index; |
|
562 | - } |
|
563 | - $engine = $engine . '/'; |
|
564 | - } |
|
565 | - |
|
566 | - $get_array = $_GET; |
|
567 | - |
|
568 | - if ( is_array( $get_array ) && ! empty( $get_array ) ) { |
|
569 | - $vars_to_maintain = array(); |
|
570 | - |
|
571 | - foreach ( $get_array as $ga_key => $ga_value ) { |
|
572 | - if ( false !== strpos( $ga_key, 'fwp_' ) ) { |
|
573 | - $vars_to_maintain[] = $ga_key . '=' . $ga_value; |
|
574 | - } |
|
575 | - } |
|
576 | - } |
|
577 | - |
|
578 | - $redirect_url = home_url( "/{$search_base}/" . $engine . urlencode( $search_query ) ); |
|
579 | - |
|
580 | - if ( ! empty( $vars_to_maintain ) ) { |
|
581 | - $redirect_url .= '?' . implode( '&', $vars_to_maintain ); |
|
582 | - } |
|
583 | - wp_redirect( $redirect_url ); |
|
584 | - exit(); |
|
585 | - } |
|
586 | - } |
|
587 | - |
|
588 | - /** |
|
589 | - * Parse the Query and trigger a search |
|
590 | - */ |
|
591 | - public function pretty_search_parse_query( $query ) { |
|
592 | - $this->post_type_slugs = array( |
|
593 | - 'post' => 'posts', |
|
594 | - 'project' => 'projects', |
|
595 | - 'service' => 'services', |
|
596 | - 'team' => 'team', |
|
597 | - 'testimonial' => 'testimonials', |
|
598 | - 'video' => 'videos', |
|
599 | - 'product' => 'products', // WooCommerce |
|
600 | - ); |
|
601 | - if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) { |
|
602 | - $search_query = $query->get( 's' ); |
|
603 | - $keyword_test = explode( '/', $search_query ); |
|
604 | - |
|
605 | - $index = array_search( $keyword_test[0], $this->post_type_slugs, true ); |
|
606 | - if ( false !== $index ) { |
|
607 | - $engine = $this->post_type_slugs[ $index ]; |
|
608 | - |
|
609 | - $query->set( 'post_type', $engine ); |
|
610 | - $query->set( 'engine', $engine ); |
|
611 | - |
|
612 | - if ( count( $keyword_test ) > 1 ) { |
|
613 | - $query->set( 's', $keyword_test[1] ); |
|
614 | - } elseif ( post_type_exists( $engine ) ) { |
|
615 | - $query->set( 's', '' ); |
|
616 | - } |
|
617 | - } else { |
|
618 | - if ( isset( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
619 | - $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
620 | - $query->set( 'post_type', $post_types ); |
|
621 | - } |
|
622 | - } |
|
623 | - } |
|
624 | - return $query; |
|
625 | - } |
|
626 | - |
|
627 | - /** |
|
628 | - * Change the search slug to /search/ for the JSON+LD output in Yoast SEO |
|
629 | - * |
|
630 | - * @return url |
|
631 | - */ |
|
632 | - public function change_json_ld_search_url() { |
|
633 | - return trailingslashit( home_url() ) . 'search/{search_term_string}'; |
|
634 | - } |
|
635 | - |
|
636 | - /** |
|
637 | - * A filter to set the layout to 2 column. |
|
638 | - */ |
|
639 | - public function lsx_layout( $layout ) { |
|
640 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
641 | - if ( false === $this->has_posts ) { |
|
642 | - $layout = '1c'; |
|
643 | - } else { |
|
644 | - $layout = $this->options['display'][ $this->search_prefix . '_layout' ]; |
|
645 | - } |
|
646 | - } |
|
647 | - return $layout; |
|
648 | - } |
|
649 | - |
|
650 | - /** |
|
651 | - * Outputs the Search Title Facet |
|
652 | - */ |
|
653 | - public function search_sidebar_top() { |
|
654 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) && true !== apply_filters( 'lsx_search_hide_search_box', false ) ) { |
|
655 | - |
|
656 | - if ( ! is_search() ) { |
|
657 | - |
|
658 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
659 | - |
|
660 | - if ( isset( $this->facet_data[ $facet ] ) && 'search' === $this->facet_data[ $facet ]['type'] ) { |
|
661 | - echo wp_kses_post( '<div class="row">' ); |
|
662 | - $this->display_facet_default( $facet ); |
|
663 | - echo wp_kses_post( '</div>' ); |
|
664 | - unset( $this->options['display'][ $this->search_prefix . '_facets' ][ $facet ] ); |
|
665 | - } |
|
666 | - } |
|
667 | - } else { |
|
668 | - echo wp_kses_post( '<div class="row">' ); |
|
669 | - $this->display_facet_search(); |
|
670 | - echo wp_kses_post( '</div>' ); |
|
671 | - } |
|
672 | - } |
|
673 | - } |
|
674 | - |
|
675 | - /** |
|
676 | - * Overrides the search facet HTML |
|
677 | - * @param $output |
|
678 | - * @param $params |
|
679 | - * |
|
680 | - * @return string |
|
681 | - */ |
|
682 | - public function search_facet_html( $output, $params ) { |
|
683 | - if ( 'search' == $params['facet']['type'] ) { |
|
684 | - |
|
685 | - $value = (array) $params['selected_values']; |
|
686 | - $value = empty( $value ) ? '' : stripslashes( $value[0] ); |
|
687 | - $placeholder = isset( $params['facet']['placeholder'] ) ? $params['facet']['placeholder'] : __( 'Search...', 'lsx-search' ); |
|
688 | - $placeholder = facetwp_i18n( $placeholder ); |
|
689 | - |
|
690 | - ob_start(); |
|
691 | - ?> |
|
12 | + /** |
|
13 | + * Holds class instance |
|
14 | + * |
|
15 | + * @since 1.0.0 |
|
16 | + * |
|
17 | + * @var object \lsx\search\classes\Frontend() |
|
18 | + */ |
|
19 | + protected static $instance = null; |
|
20 | + |
|
21 | + public $options = false; |
|
22 | + |
|
23 | + public $tabs = false; |
|
24 | + |
|
25 | + public $facet_data = false; |
|
26 | + |
|
27 | + /** |
|
28 | + * Determine weather or not search is enabled for this page. |
|
29 | + * |
|
30 | + * @var boolean |
|
31 | + */ |
|
32 | + public $search_enabled = false; |
|
33 | + |
|
34 | + public $search_core_suffix = false; |
|
35 | + |
|
36 | + public $search_prefix = false; |
|
37 | + |
|
38 | + /** |
|
39 | + * Holds the post types enabled |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + public $post_types = array(); |
|
44 | + |
|
45 | + /** |
|
46 | + * Holds the taxonomies enabled for search |
|
47 | + * |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + public $taxonomies = array(); |
|
51 | + |
|
52 | + /** |
|
53 | + * If the current search page has posts or not |
|
54 | + * |
|
55 | + * @var boolean |
|
56 | + */ |
|
57 | + public $has_posts = false; |
|
58 | + |
|
59 | + /** |
|
60 | + * If we are using the CMB2 options or not. |
|
61 | + * |
|
62 | + * @var boolean |
|
63 | + */ |
|
64 | + public $new_options = false; |
|
65 | + |
|
66 | + /** |
|
67 | + * Construct method. |
|
68 | + */ |
|
69 | + public function __construct() { |
|
70 | + $this->options = \lsx\search\includes\get_options(); |
|
71 | + $this->load_classes(); |
|
72 | + |
|
73 | + add_filter( 'wpseo_json_ld_search_url', array( $this, 'change_json_ld_search_url' ), 10, 1 ); |
|
74 | + add_action( 'wp', array( $this, 'set_vars' ), 21 ); |
|
75 | + add_action( 'wp', array( $this, 'set_facetwp_vars' ), 22 ); |
|
76 | + add_action( 'wp', array( $this, 'core' ), 23 ); |
|
77 | + add_action( 'lsx_body_top', array( $this, 'check_for_results' ) ); |
|
78 | + |
|
79 | + add_filter( 'pre_get_posts', array( $this, 'ignore_sticky_search' ) ); |
|
80 | + add_action( 'pre_get_posts', array( $this, 'filter_post_types' ) ); |
|
81 | + |
|
82 | + add_filter( 'lsx_search_post_types', array( $this, 'register_post_types' ) ); |
|
83 | + add_filter( 'lsx_search_taxonomies', array( $this, 'register_taxonomies' ) ); |
|
84 | + add_filter( 'lsx_search_post_types_plural', array( $this, 'register_post_type_tabs' ) ); |
|
85 | + add_filter( 'facetwp_sort_options', array( $this, 'facetwp_sort_options' ), 10, 2 ); |
|
86 | + add_filter( 'wp_kses_allowed_html', array( $this, 'kses_allowed_html' ), 20, 2 ); |
|
87 | + add_filter( 'get_search_query', array( $this, 'get_search_query' ) ); |
|
88 | + |
|
89 | + // Redirects. |
|
90 | + add_action( 'template_redirect', array( $this, 'pretty_search_redirect' ) ); |
|
91 | + add_filter( 'pre_get_posts', array( $this, 'pretty_search_parse_query' ) ); |
|
92 | + |
|
93 | + add_action( 'lsx_search_sidebar_top', array( $this, 'search_sidebar_top' ) ); |
|
94 | + add_filter( 'facetwp_facet_html', array( $this, 'search_facet_html' ), 10, 2 ); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Return an instance of this class. |
|
99 | + * |
|
100 | + * @since 1.0.0 |
|
101 | + * |
|
102 | + * @return object \lsx\member_directory\search\Frontend() A single instance of this class. |
|
103 | + */ |
|
104 | + public static function get_instance() { |
|
105 | + // If the single instance hasn't been set, set it now. |
|
106 | + if ( null === self::$instance ) { |
|
107 | + self::$instance = new self(); |
|
108 | + } |
|
109 | + return self::$instance; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Loads the variable classes and the static classes. |
|
114 | + */ |
|
115 | + private function load_classes() { |
|
116 | + require_once LSX_SEARCH_PATH . 'classes/frontend/class-layout.php'; |
|
117 | + $this->layout = frontend\Layout::get_instance(); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Check all settings. |
|
122 | + */ |
|
123 | + public function set_vars() { |
|
124 | + $post_type = ''; |
|
125 | + |
|
126 | + $this->post_types = apply_filters( 'lsx_search_post_types', array() ); |
|
127 | + $this->taxonomies = apply_filters( 'lsx_search_taxonomies', array() ); |
|
128 | + $this->tabs = apply_filters( 'lsx_search_post_types_plural', array() ); |
|
129 | + $this->options = apply_filters( 'lsx_search_options', $this->options ); |
|
130 | + $this->post_types = get_post_types(); |
|
131 | + $this->post_type_slugs = array( |
|
132 | + 'post' => 'posts', |
|
133 | + 'project' => 'projects', |
|
134 | + 'service' => 'services', |
|
135 | + 'team' => 'team', |
|
136 | + 'testimonial' => 'testimonials', |
|
137 | + 'video' => 'videos', |
|
138 | + 'product' => 'products', |
|
139 | + ); |
|
140 | + $this->set_search_prefix(); |
|
141 | + $this->get_cmb2_options(); |
|
142 | + $this->search_enabled = apply_filters( 'lsx_search_enabled', $this->is_search_enabled(), $this ); |
|
143 | + $this->search_prefix = apply_filters( 'lsx_search_prefix', $this->search_prefix, $this ); |
|
144 | + } |
|
145 | + |
|
146 | + private function get_cmb2_options() { |
|
147 | + $cmb2_options = get_option( 'lsx-search-settings' ); |
|
148 | + if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
149 | + $this->set_search_prefix( true ); |
|
150 | + $this->options['display'] = $cmb2_options; |
|
151 | + foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
152 | + if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
153 | + $new_values = array(); |
|
154 | + foreach ( $option_value as $empty_key => $key_value ) { |
|
155 | + $new_values[ $key_value ] = 'on'; |
|
156 | + } |
|
157 | + $this->options['display'][ $option_key ] = $new_values; |
|
158 | + } |
|
159 | + } |
|
160 | + $this->new_options = true; |
|
161 | + $this->disable_to_search_actions(); |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + private function disable_to_search_actions() { |
|
166 | + global $lsx_to_search_fwp, $lsx_to_search; |
|
167 | + if ( null !== $lsx_to_search ) { |
|
168 | + // Redirects. |
|
169 | + remove_filter( 'template_include', array( $lsx_to_search, 'search_template_include' ), 99 ); |
|
170 | + remove_action( 'template_redirect', array( $lsx_to_search, 'pretty_search_redirect' ) ); |
|
171 | + remove_filter( 'pre_get_posts', array( $lsx_to_search, 'pretty_search_parse_query' ) ); |
|
172 | + |
|
173 | + // Layout Filter. |
|
174 | + remove_filter( 'lsx_layout', array( $lsx_to_search, 'lsx_layout' ), 20, 1 ); |
|
175 | + remove_filter( 'lsx_layout_selector', array( $lsx_to_search, 'lsx_layout_selector' ), 10, 4 ); |
|
176 | + remove_filter( 'lsx_to_archive_layout', array( $lsx_to_search, 'lsx_to_search_archive_layout' ), 10, 2 ); |
|
177 | + |
|
178 | + remove_action( 'lsx_search_sidebar_top', array( $lsx_to_search, 'search_sidebar_top' ) ); |
|
179 | + remove_action( 'pre_get_posts', array( $lsx_to_search, 'price_sorting' ), 100 ); |
|
180 | + |
|
181 | + //add_shortcode( 'lsx_search_form', array( 'LSX_TO_Search_Frontend', 'search_form' ) ); |
|
182 | + remove_filter( 'searchwp_short_circuit', array( $lsx_to_search, 'searchwp_short_circuit' ), 10, 2 ); |
|
183 | + remove_filter( 'get_search_query', array( $lsx_to_search, 'get_search_query' ) ); |
|
184 | + remove_filter( 'body_class', array( $lsx_to_search, 'to_add_search_url_class' ), 20 ); |
|
185 | + |
|
186 | + remove_filter( 'facetwp_preload_url_vars', array( $lsx_to_search, 'preload_url_vars' ), 10, 1 ); |
|
187 | + remove_filter( 'wpseo_json_ld_search_url', array( $lsx_to_search, 'change_json_ld_search_url' ), 10, 1 ); |
|
188 | + } |
|
189 | + if ( null !== $lsx_to_search_fwp ) { |
|
190 | + remove_filter( 'facetwp_indexer_row_data', array( $lsx_to_search_fwp, 'facetwp_index_row_data' ), 10, 2 ); |
|
191 | + remove_filter( 'facetwp_index_row', array( $lsx_to_search_fwp, 'facetwp_index_row' ), 10, 2 ); |
|
192 | + |
|
193 | + remove_filter( 'facetwp_sort_options', array( $lsx_to_search_fwp, 'facet_sort_options' ), 10, 2 ); |
|
194 | + |
|
195 | + remove_filter( 'facetwp_pager_html', array( $lsx_to_search_fwp, 'facetwp_pager_html' ), 10, 2 ); |
|
196 | + remove_filter( 'facetwp_result_count', array( $lsx_to_search_fwp, 'facetwp_result_count' ), 10, 2 ); |
|
197 | + |
|
198 | + remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'destination_facet_html' ), 10, 2 ); |
|
199 | + remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'slide_facet_html' ), 10, 2 ); |
|
200 | + remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'search_facet_html' ), 10, 2 ); |
|
201 | + remove_filter( 'facetwp_load_css', array( $lsx_to_search_fwp, 'facetwp_load_css' ), 10, 1 ); |
|
202 | + |
|
203 | + if ( class_exists( 'LSX_Currencies' ) ) { |
|
204 | + remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_lsx_currencies' ), 10, 2 ); |
|
205 | + } else { |
|
206 | + remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_to_currencies' ), 10, 2 ); |
|
207 | + } |
|
208 | + } |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * Returns if the search is enabled. |
|
213 | + * |
|
214 | + * @return boolean |
|
215 | + */ |
|
216 | + public function is_search_enabled() { |
|
217 | + $search_enabled = false; |
|
218 | + |
|
219 | + if ( false === $this->new_options ) { |
|
220 | + if ( isset( $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) && ( ! empty( $this->options ) ) && 'on' == $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) { |
|
221 | + $search_enabled = true; |
|
222 | + } |
|
223 | + } else { |
|
224 | + $enable_prefix = $this->search_prefix; |
|
225 | + if ( ! empty( $this->options ) && isset( $this->options['display'] ) && isset( $this->options['display'][ $enable_prefix . '_enable' ] ) && 'on' === $this->options['display'][ $enable_prefix . '_enable' ] ) { |
|
226 | + $search_enabled = true; |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + // These are specific plugin exclusions. |
|
231 | + if ( is_tax( array( 'wcpv_product_vendors' ) ) ) { |
|
232 | + $search_enabled = false; |
|
233 | + } |
|
234 | + return $search_enabled; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Sets the search prefix. |
|
239 | + * |
|
240 | + * @return void |
|
241 | + */ |
|
242 | + private function set_search_prefix( $new_prefixes = false ) { |
|
243 | + $page_for_posts = get_option( 'page_for_posts' ); |
|
244 | + if ( false !== $new_prefixes ) { |
|
245 | + $this->taxonomies = array(); |
|
246 | + $this->post_types = array(); |
|
247 | + } |
|
248 | + |
|
249 | + if ( is_search() ) { |
|
250 | + if ( false === $new_prefixes ) { |
|
251 | + $this->search_core_suffix = 'core'; |
|
252 | + $this->search_prefix = 'search'; |
|
253 | + } else { |
|
254 | + $this->search_core_suffix = 'enable'; |
|
255 | + $this->search_prefix = 'engine_search'; |
|
256 | + } |
|
257 | + } elseif ( is_post_type_archive( $this->post_types ) || is_tax() || is_page( $page_for_posts ) || is_home() || is_category() || is_tag() ) { |
|
258 | + if ( false === $new_prefixes ) { |
|
259 | + $this->search_core_suffix = 'search'; |
|
260 | + } else { |
|
261 | + $this->search_core_suffix = 'enable'; |
|
262 | + } |
|
263 | + |
|
264 | + if ( is_tax() ) { |
|
265 | + $tax = get_query_var( 'taxonomy' ); |
|
266 | + $tax = get_taxonomy( $tax ); |
|
267 | + $post_type = $tax->object_type[0]; |
|
268 | + } else if ( is_page( $page_for_posts ) || is_category() || is_tag() || is_home() ) { |
|
269 | + $post_type = 'post'; |
|
270 | + } else { |
|
271 | + $post_type = get_query_var( 'post_type' ); |
|
272 | + } |
|
273 | + |
|
274 | + if ( false === $new_prefixes ) { |
|
275 | + if ( isset( $this->tabs[ $post_type ] ) ) { |
|
276 | + $this->search_prefix = $this->tabs[ $post_type ] . '_archive'; |
|
277 | + } |
|
278 | + } else { |
|
279 | + $this->search_prefix = $post_type . '_search'; |
|
280 | + } |
|
281 | + } |
|
282 | + } |
|
283 | + |
|
284 | + /** |
|
285 | + * Sets the FacetWP variables. |
|
286 | + */ |
|
287 | + public function set_facetwp_vars() { |
|
288 | + |
|
289 | + if ( class_exists( 'FacetWP' ) ) { |
|
290 | + $facet_data = FWP()->helper->get_facets(); |
|
291 | + } |
|
292 | + |
|
293 | + $this->facet_data = array(); |
|
294 | + |
|
295 | + $this->facet_data['search_form'] = array( |
|
296 | + 'name' => 'search_form', |
|
297 | + 'label' => esc_html__( 'Search Form', 'lsx-search' ), |
|
298 | + ); |
|
299 | + |
|
300 | + if ( ! empty( $facet_data ) && is_array( $facet_data ) ) { |
|
301 | + foreach ( $facet_data as $facet ) { |
|
302 | + $this->facet_data[ $facet['name'] ] = $facet; |
|
303 | + } |
|
304 | + } |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * Check all settings. |
|
309 | + */ |
|
310 | + public function core() { |
|
311 | + |
|
312 | + if ( true === $this->search_enabled ) { |
|
313 | + add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 999 ); |
|
314 | + |
|
315 | + add_filter( 'lsx_layout', array( $this, 'lsx_layout' ), 20, 1 ); |
|
316 | + add_filter( 'lsx_layout_selector', array( $this, 'lsx_layout_selector' ), 10, 4 ); |
|
317 | + add_filter( 'lsx_slot_class', array( $this, 'change_slot_column_class' ) ); |
|
318 | + add_action( 'lsx_entry_top', array( $this, 'add_label_to_title' ) ); |
|
319 | + add_filter( 'body_class', array( $this, 'body_class' ), 10 ); |
|
320 | + |
|
321 | + add_filter( 'lsx_blog_customizer_top_of_blog_action', array( $this, 'top_of_blog_action' ), 10, 1 ); |
|
322 | + add_filter( 'lsx_blog_customizer_blog_description_class', array( $this, 'blog_description_class' ), 10, 1 ); |
|
323 | + |
|
324 | + if ( class_exists( 'LSX_Videos' ) ) { |
|
325 | + global $lsx_videos_frontend; |
|
326 | + remove_action( 'lsx_content_top', array( $lsx_videos_frontend, 'categories_tabs' ), 15 ); |
|
327 | + } |
|
328 | + |
|
329 | + add_filter( 'lsx_paging_nav_disable', '__return_true' ); |
|
330 | + add_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
331 | + add_action( 'lsx_content_top', array( $this, 'facetwp_tempate_open' ) ); |
|
332 | + add_action( 'lsx_content_bottom', array( $this, 'facetwp_tempate_close' ) ); |
|
333 | + add_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
334 | + |
|
335 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) && '1c' !== $this->options['display'][ $this->search_prefix . '_layout' ] ) { |
|
336 | + add_filter( 'lsx_sidebar_enable', array( $this, 'lsx_sidebar_enable' ), 10, 1 ); |
|
337 | + } |
|
338 | + |
|
339 | + add_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
340 | + |
|
341 | + if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) { |
|
342 | + remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' ); |
|
343 | + remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' ); |
|
344 | + add_filter( 'woocommerce_show_page_title', '__return_false' ); |
|
345 | + |
|
346 | + add_filter( 'loop_shop_columns', function() { |
|
347 | + return 3; |
|
348 | + } ); |
|
349 | + |
|
350 | + // Actions added by LSX theme |
|
351 | + remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
|
352 | + add_action( 'lsx_content_wrap_before', array( $this, 'wc_archive_header' ), 140 ); |
|
353 | + |
|
354 | + // Actions added be LSX theme / woocommerce.php file |
|
355 | + remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
356 | + remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
357 | + remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 ); |
|
358 | + remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 ); |
|
359 | + remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
360 | + |
|
361 | + // Actions added be LSX theme / woocommerce.php file |
|
362 | + remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
363 | + remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
364 | + remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
365 | + remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 ); |
|
366 | + remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
367 | + } |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Adds a search class to the body to allow the styling of the sidebars etc. |
|
373 | + * |
|
374 | + * @param array $classes The classes. |
|
375 | + * @return array $classes The classes. |
|
376 | + */ |
|
377 | + public function body_class( $classes ) { |
|
378 | + $classes[] = 'lsx-search-enabled'; |
|
379 | + return $classes; |
|
380 | + } |
|
381 | + |
|
382 | + /** |
|
383 | + * Moves the blog description to above the content columns. |
|
384 | + * |
|
385 | + * @param string $action |
|
386 | + * @return string $action |
|
387 | + */ |
|
388 | + public function top_of_blog_action( $action = '' ) { |
|
389 | + $action = 'lsx_content_wrap_before'; |
|
390 | + return $action; |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Adds a class to the blog description. |
|
395 | + * |
|
396 | + * @param string $action |
|
397 | + * @return string $action |
|
398 | + */ |
|
399 | + public function blog_description_class( $class = '' ) { |
|
400 | + $class .= ' col-md-12 search-description'; |
|
401 | + return $class; |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * Check the $wp_query global to see if there are posts in the current query. |
|
406 | + * |
|
407 | + * @return void |
|
408 | + */ |
|
409 | + public function check_for_results() { |
|
410 | + if ( true === $this->search_enabled ) { |
|
411 | + global $wp_query; |
|
412 | + if ( empty( $wp_query->posts ) ) { |
|
413 | + $this->has_posts = false; |
|
414 | + remove_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
415 | + remove_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
416 | + remove_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
417 | + } else { |
|
418 | + $this->has_posts = true; |
|
419 | + } |
|
420 | + } |
|
421 | + } |
|
422 | + |
|
423 | + /** |
|
424 | + * Filter the post types. |
|
425 | + */ |
|
426 | + public function filter_post_types( $query ) { |
|
427 | + if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { |
|
428 | + if ( ! empty( $this->options ) && ! empty( $this->options['display']['search_enable_core'] ) ) { |
|
429 | + if ( ! empty( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
430 | + $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
431 | + $query->set( 'post_type', $post_types ); |
|
432 | + } |
|
433 | + } |
|
434 | + } |
|
435 | + } |
|
436 | + |
|
437 | + /** |
|
438 | + * Sets post types with active search options. |
|
439 | + */ |
|
440 | + public function register_post_types( $post_types ) { |
|
441 | + $post_types = array( 'post', 'project', 'service', 'team', 'testimonial', 'video', 'product' ); |
|
442 | + return $post_types; |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * Sets taxonomies with active search options. |
|
447 | + */ |
|
448 | + public function register_taxonomies( $taxonomies ) { |
|
449 | + $taxonomies = array( 'category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag' ); |
|
450 | + return $taxonomies; |
|
451 | + } |
|
452 | + |
|
453 | + /** |
|
454 | + * Sets post types with active search options. |
|
455 | + */ |
|
456 | + public function register_post_type_tabs( $post_types_plural ) { |
|
457 | + $post_types_plural = array( |
|
458 | + 'post' => 'posts', |
|
459 | + 'project' => 'projects', |
|
460 | + 'service' => 'services', |
|
461 | + 'team' => 'team', |
|
462 | + 'testimonial' => 'testimonials', |
|
463 | + 'video' => 'videos', |
|
464 | + 'product' => 'products', // WooCommerce |
|
465 | + ); |
|
466 | + return $post_types_plural; |
|
467 | + } |
|
468 | + |
|
469 | + /** |
|
470 | + * Enqueue styles and scripts. |
|
471 | + */ |
|
472 | + public function assets() { |
|
473 | + add_filter( 'lsx_defer_parsing_of_js', array( $this, 'skip_js_defer' ), 10, 4 ); |
|
474 | + wp_enqueue_script( 'touchSwipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.touchSwipe.min.js', array( 'jquery' ), LSX_SEARCH_VER, true ); |
|
475 | + wp_enqueue_script( 'slideandswipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.slideandswipe.min.js', array( 'jquery', 'touchSwipe' ), LSX_SEARCH_VER, true ); |
|
476 | + wp_enqueue_script( 'lsx-search', LSX_SEARCH_URL . 'assets/js/src/lsx-search.js', array( 'jquery', 'touchSwipe', 'slideandswipe', 'jquery-ui-datepicker' ), LSX_SEARCH_VER, true ); |
|
477 | + |
|
478 | + $params = apply_filters( 'lsx_search_js_params', array( |
|
479 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
480 | + )); |
|
481 | + |
|
482 | + wp_localize_script( 'lsx-search', 'lsx_customizer_params', $params ); |
|
483 | + |
|
484 | + wp_enqueue_style( 'lsx-search', LSX_SEARCH_URL . 'assets/css/lsx-search.css', array(), LSX_SEARCH_VER ); |
|
485 | + wp_style_add_data( 'lsx-search', 'rtl', 'replace' ); |
|
486 | + |
|
487 | + if ( true === $this->new_options ) { |
|
488 | + wp_deregister_style( 'lsx_to_search' ); |
|
489 | + wp_deregister_script( 'lsx_to_search' ); |
|
490 | + } |
|
491 | + } |
|
492 | + |
|
493 | + /** |
|
494 | + * Adds the to-search.min.js and the to-search.js |
|
495 | + * |
|
496 | + * @param boolean $should_skip |
|
497 | + * @param string $tag |
|
498 | + * @param string $handle |
|
499 | + * @param string $href |
|
500 | + * @return boolean |
|
501 | + */ |
|
502 | + public function skip_js_defer( $should_skip, $tag, $handle, $href ) { |
|
503 | + if ( ! is_admin() && ( false !== stripos( $href, 'lsx-search.min.js' ) || false !== stripos( $href, 'lsx-search.js' ) ) ) { |
|
504 | + $should_skip = true; |
|
505 | + } |
|
506 | + return $should_skip; |
|
507 | + } |
|
508 | + |
|
509 | + /** |
|
510 | + * Redirect wordpress to the search template located in the plugin |
|
511 | + * |
|
512 | + * @param $template |
|
513 | + * @return $template |
|
514 | + */ |
|
515 | + public function search_template_include( $template ) { |
|
516 | + if ( is_main_query() && is_search() ) { |
|
517 | + if ( file_exists( LSX_SEARCH_PATH . 'templates/search.php' ) ) { |
|
518 | + $template = LSX_SEARCH_PATH . 'templates/search.php'; |
|
519 | + } |
|
520 | + } |
|
521 | + |
|
522 | + return $template; |
|
523 | + } |
|
524 | + |
|
525 | + /** |
|
526 | + * Ignore sticky posts on Blog search. |
|
527 | + * |
|
528 | + * @param [type] $query |
|
529 | + * @return void |
|
530 | + */ |
|
531 | + public function ignore_sticky_search( $query ) { |
|
532 | + if ( $query->is_main_query() && is_home() ) { |
|
533 | + $query->set( 'ignore_sticky_posts', true ); |
|
534 | + } |
|
535 | + } |
|
536 | + |
|
537 | + /** |
|
538 | + * Rewrite the search URL |
|
539 | + */ |
|
540 | + public function pretty_search_redirect() { |
|
541 | + global $wp_rewrite,$wp_query; |
|
542 | + |
|
543 | + if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
544 | + return; |
|
545 | + } |
|
546 | + |
|
547 | + $search_base = $wp_rewrite->search_base; |
|
548 | + |
|
549 | + if ( is_search() && ! is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { |
|
550 | + $search_query = get_query_var( 's' ); |
|
551 | + if ( empty( $search_query ) && isset( $_GET['s'] ) ) { |
|
552 | + $search_query = $_GET['s']; |
|
553 | + } |
|
554 | + $engine = ''; |
|
555 | + |
|
556 | + // If the search was triggered by a supplemental engine. |
|
557 | + if ( isset( $_GET['engine'] ) && 'default' !== $_GET['engine'] ) { |
|
558 | + $engine = sanitize_text_field( wp_unslash( $_GET['engine'] ) ); |
|
559 | + $index = array_search( $engine, $this->post_type_slugs, true ); |
|
560 | + if ( false !== $index ) { |
|
561 | + $engine = $index; |
|
562 | + } |
|
563 | + $engine = $engine . '/'; |
|
564 | + } |
|
565 | + |
|
566 | + $get_array = $_GET; |
|
567 | + |
|
568 | + if ( is_array( $get_array ) && ! empty( $get_array ) ) { |
|
569 | + $vars_to_maintain = array(); |
|
570 | + |
|
571 | + foreach ( $get_array as $ga_key => $ga_value ) { |
|
572 | + if ( false !== strpos( $ga_key, 'fwp_' ) ) { |
|
573 | + $vars_to_maintain[] = $ga_key . '=' . $ga_value; |
|
574 | + } |
|
575 | + } |
|
576 | + } |
|
577 | + |
|
578 | + $redirect_url = home_url( "/{$search_base}/" . $engine . urlencode( $search_query ) ); |
|
579 | + |
|
580 | + if ( ! empty( $vars_to_maintain ) ) { |
|
581 | + $redirect_url .= '?' . implode( '&', $vars_to_maintain ); |
|
582 | + } |
|
583 | + wp_redirect( $redirect_url ); |
|
584 | + exit(); |
|
585 | + } |
|
586 | + } |
|
587 | + |
|
588 | + /** |
|
589 | + * Parse the Query and trigger a search |
|
590 | + */ |
|
591 | + public function pretty_search_parse_query( $query ) { |
|
592 | + $this->post_type_slugs = array( |
|
593 | + 'post' => 'posts', |
|
594 | + 'project' => 'projects', |
|
595 | + 'service' => 'services', |
|
596 | + 'team' => 'team', |
|
597 | + 'testimonial' => 'testimonials', |
|
598 | + 'video' => 'videos', |
|
599 | + 'product' => 'products', // WooCommerce |
|
600 | + ); |
|
601 | + if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) { |
|
602 | + $search_query = $query->get( 's' ); |
|
603 | + $keyword_test = explode( '/', $search_query ); |
|
604 | + |
|
605 | + $index = array_search( $keyword_test[0], $this->post_type_slugs, true ); |
|
606 | + if ( false !== $index ) { |
|
607 | + $engine = $this->post_type_slugs[ $index ]; |
|
608 | + |
|
609 | + $query->set( 'post_type', $engine ); |
|
610 | + $query->set( 'engine', $engine ); |
|
611 | + |
|
612 | + if ( count( $keyword_test ) > 1 ) { |
|
613 | + $query->set( 's', $keyword_test[1] ); |
|
614 | + } elseif ( post_type_exists( $engine ) ) { |
|
615 | + $query->set( 's', '' ); |
|
616 | + } |
|
617 | + } else { |
|
618 | + if ( isset( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
619 | + $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
620 | + $query->set( 'post_type', $post_types ); |
|
621 | + } |
|
622 | + } |
|
623 | + } |
|
624 | + return $query; |
|
625 | + } |
|
626 | + |
|
627 | + /** |
|
628 | + * Change the search slug to /search/ for the JSON+LD output in Yoast SEO |
|
629 | + * |
|
630 | + * @return url |
|
631 | + */ |
|
632 | + public function change_json_ld_search_url() { |
|
633 | + return trailingslashit( home_url() ) . 'search/{search_term_string}'; |
|
634 | + } |
|
635 | + |
|
636 | + /** |
|
637 | + * A filter to set the layout to 2 column. |
|
638 | + */ |
|
639 | + public function lsx_layout( $layout ) { |
|
640 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
641 | + if ( false === $this->has_posts ) { |
|
642 | + $layout = '1c'; |
|
643 | + } else { |
|
644 | + $layout = $this->options['display'][ $this->search_prefix . '_layout' ]; |
|
645 | + } |
|
646 | + } |
|
647 | + return $layout; |
|
648 | + } |
|
649 | + |
|
650 | + /** |
|
651 | + * Outputs the Search Title Facet |
|
652 | + */ |
|
653 | + public function search_sidebar_top() { |
|
654 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) && true !== apply_filters( 'lsx_search_hide_search_box', false ) ) { |
|
655 | + |
|
656 | + if ( ! is_search() ) { |
|
657 | + |
|
658 | + foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
659 | + |
|
660 | + if ( isset( $this->facet_data[ $facet ] ) && 'search' === $this->facet_data[ $facet ]['type'] ) { |
|
661 | + echo wp_kses_post( '<div class="row">' ); |
|
662 | + $this->display_facet_default( $facet ); |
|
663 | + echo wp_kses_post( '</div>' ); |
|
664 | + unset( $this->options['display'][ $this->search_prefix . '_facets' ][ $facet ] ); |
|
665 | + } |
|
666 | + } |
|
667 | + } else { |
|
668 | + echo wp_kses_post( '<div class="row">' ); |
|
669 | + $this->display_facet_search(); |
|
670 | + echo wp_kses_post( '</div>' ); |
|
671 | + } |
|
672 | + } |
|
673 | + } |
|
674 | + |
|
675 | + /** |
|
676 | + * Overrides the search facet HTML |
|
677 | + * @param $output |
|
678 | + * @param $params |
|
679 | + * |
|
680 | + * @return string |
|
681 | + */ |
|
682 | + public function search_facet_html( $output, $params ) { |
|
683 | + if ( 'search' == $params['facet']['type'] ) { |
|
684 | + |
|
685 | + $value = (array) $params['selected_values']; |
|
686 | + $value = empty( $value ) ? '' : stripslashes( $value[0] ); |
|
687 | + $placeholder = isset( $params['facet']['placeholder'] ) ? $params['facet']['placeholder'] : __( 'Search...', 'lsx-search' ); |
|
688 | + $placeholder = facetwp_i18n( $placeholder ); |
|
689 | + |
|
690 | + ob_start(); |
|
691 | + ?> |
|
692 | 692 | <div class="col-xs-12 facetwp-item facetwp-form"> |
693 | 693 | <div class="search-form lsx-search-form 2"> |
694 | 694 | <div class="input-group facetwp-search-wrap"> |
@@ -703,75 +703,75 @@ discard block |
||
703 | 703 | </div> |
704 | 704 | </div> |
705 | 705 | <?php |
706 | - $output = ob_get_clean(); |
|
707 | - } |
|
708 | - return $output; |
|
709 | - } |
|
710 | - |
|
711 | - /** |
|
712 | - * Change the primary and secondary column classes. |
|
713 | - */ |
|
714 | - public function lsx_layout_selector( $return_class, $class, $layout, $size ) { |
|
715 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
716 | - |
|
717 | - if ( '2cl' === $layout || '2cr' === $layout ) { |
|
718 | - $main_class = 'col-sm-8 col-md-9'; |
|
719 | - $sidebar_class = 'col-sm-4 col-md-3'; |
|
720 | - |
|
721 | - if ( '2cl' === $layout ) { |
|
722 | - $main_class .= ' col-sm-pull-4 col-md-pull-3 search-sidebar-left'; |
|
723 | - $sidebar_class .= ' col-sm-push-8 col-md-push-9'; |
|
724 | - } |
|
725 | - |
|
726 | - if ( 'main' === $class ) { |
|
727 | - return $main_class; |
|
728 | - } |
|
729 | - |
|
730 | - if ( 'sidebar' === $class ) { |
|
731 | - return $sidebar_class; |
|
732 | - } |
|
733 | - } |
|
734 | - } |
|
735 | - |
|
736 | - return $return_class; |
|
737 | - } |
|
738 | - |
|
739 | - /** |
|
740 | - * Displays the Alphabet sorter above the facets. |
|
741 | - * |
|
742 | - * @return void |
|
743 | - */ |
|
744 | - public function display_alphabet_facet() { |
|
745 | - if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
746 | - $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
747 | - } else { |
|
748 | - $az_pagination = false; |
|
749 | - } |
|
750 | - $az_pagination = apply_filters( 'lsx_search_top_az_pagination', $az_pagination ); |
|
751 | - if ( false !== $az_pagination && '' !== $az_pagination ) { |
|
752 | - echo do_shortcode( '[facetwp facet="' . $az_pagination . '"]' ); |
|
753 | - } |
|
754 | - } |
|
755 | - |
|
756 | - /** |
|
757 | - * Outputs top. |
|
758 | - */ |
|
759 | - public function facet_top_bar() { |
|
760 | - if ( true === apply_filters( 'lsx_search_hide_top_bar', false ) ) { |
|
761 | - return; |
|
762 | - } |
|
763 | - |
|
764 | - $show_pagination = true; |
|
765 | - $pagination_visible = false; |
|
766 | - $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
767 | - $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_sorting' ] ); |
|
768 | - |
|
769 | - $show_pagination = apply_filters( 'lsx_search_top_show_pagination', $show_pagination ); |
|
770 | - $pagination_visible = apply_filters( 'lsx_search_top_pagination_visible', $pagination_visible ); |
|
771 | - $show_per_page_combo = apply_filters( 'lsx_search_top_show_per_page_combo', $show_per_page_combo ); |
|
772 | - $show_sort_combo = apply_filters( 'lsx_search_top_show_sort_combo', $show_sort_combo ); |
|
773 | - $facet_row_classes = apply_filters( 'lsx_search_top_facetwp_row_classes', '' ); |
|
774 | - ?> |
|
706 | + $output = ob_get_clean(); |
|
707 | + } |
|
708 | + return $output; |
|
709 | + } |
|
710 | + |
|
711 | + /** |
|
712 | + * Change the primary and secondary column classes. |
|
713 | + */ |
|
714 | + public function lsx_layout_selector( $return_class, $class, $layout, $size ) { |
|
715 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
716 | + |
|
717 | + if ( '2cl' === $layout || '2cr' === $layout ) { |
|
718 | + $main_class = 'col-sm-8 col-md-9'; |
|
719 | + $sidebar_class = 'col-sm-4 col-md-3'; |
|
720 | + |
|
721 | + if ( '2cl' === $layout ) { |
|
722 | + $main_class .= ' col-sm-pull-4 col-md-pull-3 search-sidebar-left'; |
|
723 | + $sidebar_class .= ' col-sm-push-8 col-md-push-9'; |
|
724 | + } |
|
725 | + |
|
726 | + if ( 'main' === $class ) { |
|
727 | + return $main_class; |
|
728 | + } |
|
729 | + |
|
730 | + if ( 'sidebar' === $class ) { |
|
731 | + return $sidebar_class; |
|
732 | + } |
|
733 | + } |
|
734 | + } |
|
735 | + |
|
736 | + return $return_class; |
|
737 | + } |
|
738 | + |
|
739 | + /** |
|
740 | + * Displays the Alphabet sorter above the facets. |
|
741 | + * |
|
742 | + * @return void |
|
743 | + */ |
|
744 | + public function display_alphabet_facet() { |
|
745 | + if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
746 | + $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
747 | + } else { |
|
748 | + $az_pagination = false; |
|
749 | + } |
|
750 | + $az_pagination = apply_filters( 'lsx_search_top_az_pagination', $az_pagination ); |
|
751 | + if ( false !== $az_pagination && '' !== $az_pagination ) { |
|
752 | + echo do_shortcode( '[facetwp facet="' . $az_pagination . '"]' ); |
|
753 | + } |
|
754 | + } |
|
755 | + |
|
756 | + /** |
|
757 | + * Outputs top. |
|
758 | + */ |
|
759 | + public function facet_top_bar() { |
|
760 | + if ( true === apply_filters( 'lsx_search_hide_top_bar', false ) ) { |
|
761 | + return; |
|
762 | + } |
|
763 | + |
|
764 | + $show_pagination = true; |
|
765 | + $pagination_visible = false; |
|
766 | + $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
767 | + $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_sorting' ] ); |
|
768 | + |
|
769 | + $show_pagination = apply_filters( 'lsx_search_top_show_pagination', $show_pagination ); |
|
770 | + $pagination_visible = apply_filters( 'lsx_search_top_pagination_visible', $pagination_visible ); |
|
771 | + $show_per_page_combo = apply_filters( 'lsx_search_top_show_per_page_combo', $show_per_page_combo ); |
|
772 | + $show_sort_combo = apply_filters( 'lsx_search_top_show_sort_combo', $show_sort_combo ); |
|
773 | + $facet_row_classes = apply_filters( 'lsx_search_top_facetwp_row_classes', '' ); |
|
774 | + ?> |
|
775 | 775 | <div id="facetwp-top"> |
776 | 776 | <?php if ( $show_sort_combo || ( $show_pagination && $show_per_page_combo ) ) { ?> |
777 | 777 | <div class="row facetwp-top-row-1 hidden-xs <?php echo esc_attr( $facet_row_classes ); ?>"> |
@@ -802,32 +802,32 @@ discard block |
||
802 | 802 | <?php } ?> |
803 | 803 | </div> |
804 | 804 | <?php |
805 | - } |
|
806 | - |
|
807 | - /** |
|
808 | - * Outputs bottom. |
|
809 | - */ |
|
810 | - public function facet_bottom_bar() { |
|
811 | - if ( true === apply_filters( 'lsx_search_hide_bottom_bar', false ) ) { |
|
812 | - return; |
|
813 | - } |
|
814 | - $show_pagination = true; |
|
815 | - $pagination_visible = false; |
|
816 | - if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
817 | - $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
818 | - } else { |
|
819 | - $az_pagination = false; |
|
820 | - } |
|
821 | - |
|
822 | - $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
823 | - $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_search_disable_sorting' ] ); |
|
824 | - |
|
825 | - $show_pagination = apply_filters( 'lsx_search_bottom_show_pagination', $show_pagination ); |
|
826 | - $pagination_visible = apply_filters( 'lsx_search_bottom_pagination_visible', $pagination_visible ); |
|
827 | - $show_per_page_combo = apply_filters( 'lsx_search_bottom_show_per_page_combo', $show_per_page_combo ); |
|
828 | - $show_sort_combo = apply_filters( 'lsx_search_bottom_show_sort_combo', $show_sort_combo ); |
|
829 | - |
|
830 | - if ( $show_pagination || ! empty( $az_pagination ) ) { ?> |
|
805 | + } |
|
806 | + |
|
807 | + /** |
|
808 | + * Outputs bottom. |
|
809 | + */ |
|
810 | + public function facet_bottom_bar() { |
|
811 | + if ( true === apply_filters( 'lsx_search_hide_bottom_bar', false ) ) { |
|
812 | + return; |
|
813 | + } |
|
814 | + $show_pagination = true; |
|
815 | + $pagination_visible = false; |
|
816 | + if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
817 | + $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
818 | + } else { |
|
819 | + $az_pagination = false; |
|
820 | + } |
|
821 | + |
|
822 | + $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
823 | + $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_search_disable_sorting' ] ); |
|
824 | + |
|
825 | + $show_pagination = apply_filters( 'lsx_search_bottom_show_pagination', $show_pagination ); |
|
826 | + $pagination_visible = apply_filters( 'lsx_search_bottom_pagination_visible', $pagination_visible ); |
|
827 | + $show_per_page_combo = apply_filters( 'lsx_search_bottom_show_per_page_combo', $show_per_page_combo ); |
|
828 | + $show_sort_combo = apply_filters( 'lsx_search_bottom_show_sort_combo', $show_sort_combo ); |
|
829 | + |
|
830 | + if ( $show_pagination || ! empty( $az_pagination ) ) { ?> |
|
831 | 831 | <div id="facetwp-bottom"> |
832 | 832 | <div class="row facetwp-bottom-row-1"> |
833 | 833 | <div class="col-xs-12"> |
@@ -842,61 +842,61 @@ discard block |
||
842 | 842 | <?php //} ?> |
843 | 843 | |
844 | 844 | <?php |
845 | - if ( $show_pagination ) { |
|
846 | - $output_pagination = do_shortcode( '[facetwp pager="true"]' ); |
|
847 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
848 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
849 | - if ( isset( $this->facet_data[ $facet ] ) && in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
850 | - $output_pagination = do_shortcode( '[facetwp facet="pager_"]' ); |
|
851 | - } |
|
852 | - } |
|
853 | - } |
|
854 | - echo wp_kses_post( $output_pagination ); |
|
855 | - ?> |
|
845 | + if ( $show_pagination ) { |
|
846 | + $output_pagination = do_shortcode( '[facetwp pager="true"]' ); |
|
847 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
848 | + foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
849 | + if ( isset( $this->facet_data[ $facet ] ) && in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
850 | + $output_pagination = do_shortcode( '[facetwp facet="pager_"]' ); |
|
851 | + } |
|
852 | + } |
|
853 | + } |
|
854 | + echo wp_kses_post( $output_pagination ); |
|
855 | + ?> |
|
856 | 856 | <?php } ?> |
857 | 857 | </div> |
858 | 858 | </div> |
859 | 859 | </div> |
860 | 860 | <?php } |
861 | - } |
|
862 | - |
|
863 | - /** |
|
864 | - * Adds in the closing facetwp div |
|
865 | - * |
|
866 | - * @return void |
|
867 | - */ |
|
868 | - public function facetwp_tempate_open() { |
|
869 | - ?> |
|
861 | + } |
|
862 | + |
|
863 | + /** |
|
864 | + * Adds in the closing facetwp div |
|
865 | + * |
|
866 | + * @return void |
|
867 | + */ |
|
868 | + public function facetwp_tempate_open() { |
|
869 | + ?> |
|
870 | 870 | <div class="facetwp-template"> |
871 | 871 | <?php |
872 | - } |
|
873 | - |
|
874 | - /** |
|
875 | - * Adds in the closing facetwp div |
|
876 | - * |
|
877 | - * @return void |
|
878 | - */ |
|
879 | - public function facetwp_tempate_close() { |
|
880 | - ?> |
|
872 | + } |
|
873 | + |
|
874 | + /** |
|
875 | + * Adds in the closing facetwp div |
|
876 | + * |
|
877 | + * @return void |
|
878 | + */ |
|
879 | + public function facetwp_tempate_close() { |
|
880 | + ?> |
|
881 | 881 | </div> |
882 | 882 | <?php |
883 | - } |
|
884 | - |
|
885 | - /** |
|
886 | - * Disables default sidebar. |
|
887 | - */ |
|
888 | - public function lsx_sidebar_enable( $sidebar_enabled ) { |
|
889 | - $sidebar_enabled = false; |
|
890 | - return $sidebar_enabled; |
|
891 | - } |
|
892 | - |
|
893 | - /** |
|
894 | - * Outputs custom sidebar. |
|
895 | - */ |
|
896 | - public function search_sidebar() { |
|
897 | - |
|
898 | - $this->options = apply_filters( 'lsx_search_sidebar_options', $this->options ); |
|
899 | - ?> |
|
883 | + } |
|
884 | + |
|
885 | + /** |
|
886 | + * Disables default sidebar. |
|
887 | + */ |
|
888 | + public function lsx_sidebar_enable( $sidebar_enabled ) { |
|
889 | + $sidebar_enabled = false; |
|
890 | + return $sidebar_enabled; |
|
891 | + } |
|
892 | + |
|
893 | + /** |
|
894 | + * Outputs custom sidebar. |
|
895 | + */ |
|
896 | + public function search_sidebar() { |
|
897 | + |
|
898 | + $this->options = apply_filters( 'lsx_search_sidebar_options', $this->options ); |
|
899 | + ?> |
|
900 | 900 | <?php do_action( 'lsx_search_sidebar_before' ); ?> |
901 | 901 | |
902 | 902 | <div id="secondary" class="facetwp-sidebar widget-area <?php echo esc_attr( lsx_sidebar_class() ); ?>" role="complementary"> |
@@ -921,13 +921,13 @@ discard block |
||
921 | 921 | |
922 | 922 | <div class="row"> |
923 | 923 | <?php |
924 | - // Slider. |
|
925 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
926 | - if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'alpha', 'search', 'pager' ) ) ) { |
|
927 | - $this->display_facet_default( $facet ); |
|
928 | - } |
|
929 | - } |
|
930 | - ?> |
|
924 | + // Slider. |
|
925 | + foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
926 | + if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'alpha', 'search', 'pager' ) ) ) { |
|
927 | + $this->display_facet_default( $facet ); |
|
928 | + } |
|
929 | + } |
|
930 | + ?> |
|
931 | 931 | </div> |
932 | 932 | |
933 | 933 | <div class="row hidden-sm hidden-md hidden-lg ssm-row-margin-top"> |
@@ -944,35 +944,35 @@ discard block |
||
944 | 944 | |
945 | 945 | <?php do_action( 'lsx_search_sidebar_after' ); ?> |
946 | 946 | <?php |
947 | - } |
|
948 | - |
|
949 | - /** |
|
950 | - * Check if the pager facet is on |
|
951 | - * |
|
952 | - * @return void |
|
953 | - */ |
|
954 | - public function pager_facet_enabled() { |
|
955 | - |
|
956 | - $pager_facet_off = false; |
|
957 | - |
|
958 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
959 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
960 | - if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
961 | - $pager_facet_off = true; |
|
962 | - } |
|
963 | - } |
|
964 | - } |
|
965 | - |
|
966 | - return $pager_facet_off; |
|
967 | - } |
|
968 | - |
|
969 | - /** |
|
970 | - * Display WooCommerce archive title. |
|
971 | - */ |
|
972 | - public function wc_archive_header() { |
|
973 | - $default_size = 'sm'; |
|
974 | - $size = apply_filters( 'lsx_bootstrap_column_size', $default_size ); |
|
975 | - ?> |
|
947 | + } |
|
948 | + |
|
949 | + /** |
|
950 | + * Check if the pager facet is on |
|
951 | + * |
|
952 | + * @return void |
|
953 | + */ |
|
954 | + public function pager_facet_enabled() { |
|
955 | + |
|
956 | + $pager_facet_off = false; |
|
957 | + |
|
958 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
959 | + foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
960 | + if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
961 | + $pager_facet_off = true; |
|
962 | + } |
|
963 | + } |
|
964 | + } |
|
965 | + |
|
966 | + return $pager_facet_off; |
|
967 | + } |
|
968 | + |
|
969 | + /** |
|
970 | + * Display WooCommerce archive title. |
|
971 | + */ |
|
972 | + public function wc_archive_header() { |
|
973 | + $default_size = 'sm'; |
|
974 | + $size = apply_filters( 'lsx_bootstrap_column_size', $default_size ); |
|
975 | + ?> |
|
976 | 976 | <div class="archive-header-wrapper banner-woocommerce col-<?php echo esc_attr( $size ); ?>-12"> |
977 | 977 | <?php lsx_global_header_inner_bottom(); ?> |
978 | 978 | <header class="archive-header"> |
@@ -980,13 +980,13 @@ discard block |
||
980 | 980 | </header> |
981 | 981 | </div> |
982 | 982 | <?php |
983 | - } |
|
983 | + } |
|
984 | 984 | |
985 | - /** |
|
986 | - * Display facet search. |
|
987 | - */ |
|
988 | - public function display_facet_search() { |
|
989 | - ?> |
|
985 | + /** |
|
986 | + * Display facet search. |
|
987 | + */ |
|
988 | + public function display_facet_search() { |
|
989 | + ?> |
|
990 | 990 | <div class="col-xs-12 facetwp-item facetwp-form"> |
991 | 991 | <form class="search-form lsx-search-form" action="<?php echo esc_attr( home_url() ); ?>" method="get"> |
992 | 992 | <div class="input-group"> |
@@ -1001,17 +1001,17 @@ discard block |
||
1001 | 1001 | </form> |
1002 | 1002 | </div> |
1003 | 1003 | <?php |
1004 | - } |
|
1004 | + } |
|
1005 | 1005 | |
1006 | - /** |
|
1007 | - * Display facet default. |
|
1008 | - */ |
|
1009 | - public function display_facet_default( $facet ) { |
|
1006 | + /** |
|
1007 | + * Display facet default. |
|
1008 | + */ |
|
1009 | + public function display_facet_default( $facet ) { |
|
1010 | 1010 | |
1011 | - $show_collapse = ! isset( $this->options['display'][$this->search_prefix . '_collapse'] ) || 'on' !== $this->options['display'][$this->search_prefix . '_collapse']; |
|
1012 | - $col_class = ''; |
|
1011 | + $show_collapse = ! isset( $this->options['display'][$this->search_prefix . '_collapse'] ) || 'on' !== $this->options['display'][$this->search_prefix . '_collapse']; |
|
1012 | + $col_class = ''; |
|
1013 | 1013 | |
1014 | - if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?> |
|
1014 | + if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?> |
|
1015 | 1015 | <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
1016 | 1016 | <?php else : ?> |
1017 | 1017 | <div class="col-xs-12 facetwp-item parent-facetwp-facet-<?php echo esc_html( $facet ); ?> <?php echo esc_attr( $col_class ); ?>"> |
@@ -1029,101 +1029,101 @@ discard block |
||
1029 | 1029 | <?php } ?> |
1030 | 1030 | </div> |
1031 | 1031 | <?php |
1032 | - endif; |
|
1033 | - } |
|
1034 | - |
|
1035 | - /** |
|
1036 | - * Changes slot column class. |
|
1037 | - */ |
|
1038 | - public function change_slot_column_class( $class ) { |
|
1039 | - if ( is_post_type_archive( 'video' ) || is_tax( 'video-category' ) ) { |
|
1040 | - $column_class = 'col-xs-12 col-sm-4'; |
|
1041 | - } |
|
1042 | - |
|
1043 | - return $column_class; |
|
1044 | - } |
|
1045 | - |
|
1046 | - /** |
|
1047 | - * Add post type label to the title. |
|
1048 | - */ |
|
1049 | - public function add_label_to_title() { |
|
1050 | - if ( is_search() ) { |
|
1051 | - if ( ! empty( $this->options['display']['engine_search_enable_pt_label'] ) ) { |
|
1052 | - $post_type = get_post_type(); |
|
1053 | - $post_type = str_replace( '_', ' ', $post_type ); |
|
1054 | - $post_type = str_replace( '-', ' ', $post_type ); |
|
1055 | - if ( 'tribe events' === $post_type ) { |
|
1056 | - $post_type = 'Events'; |
|
1057 | - } |
|
1058 | - echo wp_kses_post( ' <span class="label label-default lsx-label-post-type">' . $post_type . '</span>' ); |
|
1059 | - } |
|
1060 | - } |
|
1061 | - } |
|
1062 | - |
|
1063 | - /** |
|
1064 | - * Changes the sort options. |
|
1065 | - */ |
|
1066 | - public function facetwp_sort_options( $options, $params ) { |
|
1067 | - $this->set_vars(); |
|
1068 | - |
|
1069 | - if ( true === $this->search_enabled ) { |
|
1070 | - if ( 'default' !== $params['template_name'] && 'wp' !== $params['template_name'] ) { |
|
1071 | - return $options; |
|
1072 | - } |
|
1073 | - |
|
1074 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_date' ] ) ) { |
|
1075 | - unset( $options['date_desc'] ); |
|
1076 | - unset( $options['date_asc'] ); |
|
1077 | - } |
|
1078 | - |
|
1079 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_az_sorting' ] ) ) { |
|
1080 | - unset( $options['title_desc'] ); |
|
1081 | - unset( $options['title_asc'] ); |
|
1082 | - } |
|
1083 | - } |
|
1084 | - |
|
1085 | - return $options; |
|
1086 | - } |
|
1087 | - |
|
1088 | - /** |
|
1089 | - * @param $allowedtags |
|
1090 | - * @param $context |
|
1091 | - * |
|
1092 | - * @return mixed |
|
1093 | - */ |
|
1094 | - public function kses_allowed_html( $allowedtags, $context ) { |
|
1095 | - $allowedtags['a']['data-value'] = true; |
|
1096 | - $allowedtags['a']['data-selection'] = true; |
|
1097 | - $allowedtags['button']['data-toggle'] = true; |
|
1098 | - return $allowedtags; |
|
1099 | - } |
|
1100 | - |
|
1101 | - /** |
|
1102 | - * Change FaceWP result count HTML |
|
1103 | - */ |
|
1104 | - public function get_search_query( $keyword ) { |
|
1105 | - global $wp_rewrite,$wp_query; |
|
1106 | - |
|
1107 | - if ( empty( $keyword ) ) { |
|
1108 | - if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
1109 | - return; |
|
1110 | - } |
|
1111 | - $search_base = $wp_rewrite->search_base; |
|
1112 | - if ( strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) !== false ) { |
|
1113 | - $words = explode( "/{$search_base}/", $_SERVER['REQUEST_URI'] ); |
|
1114 | - $limit = count( $words ); |
|
1115 | - if ( isset( $words[ $limit - 1 ] ) ) { |
|
1116 | - $keyword = $words[ $limit - 1 ]; |
|
1117 | - } |
|
1118 | - } |
|
1119 | - } |
|
1120 | - |
|
1121 | - $needle = trim( '/ ' ); |
|
1122 | - $words = explode( $needle, $keyword ); |
|
1123 | - if ( is_array( $words ) && ! empty( $words ) ) { |
|
1124 | - $keyword = $words[ count( $words ) - 1 ]; |
|
1125 | - } |
|
1126 | - $keyword = str_replace( '+', ' ', $keyword ); |
|
1127 | - return $keyword; |
|
1128 | - } |
|
1032 | + endif; |
|
1033 | + } |
|
1034 | + |
|
1035 | + /** |
|
1036 | + * Changes slot column class. |
|
1037 | + */ |
|
1038 | + public function change_slot_column_class( $class ) { |
|
1039 | + if ( is_post_type_archive( 'video' ) || is_tax( 'video-category' ) ) { |
|
1040 | + $column_class = 'col-xs-12 col-sm-4'; |
|
1041 | + } |
|
1042 | + |
|
1043 | + return $column_class; |
|
1044 | + } |
|
1045 | + |
|
1046 | + /** |
|
1047 | + * Add post type label to the title. |
|
1048 | + */ |
|
1049 | + public function add_label_to_title() { |
|
1050 | + if ( is_search() ) { |
|
1051 | + if ( ! empty( $this->options['display']['engine_search_enable_pt_label'] ) ) { |
|
1052 | + $post_type = get_post_type(); |
|
1053 | + $post_type = str_replace( '_', ' ', $post_type ); |
|
1054 | + $post_type = str_replace( '-', ' ', $post_type ); |
|
1055 | + if ( 'tribe events' === $post_type ) { |
|
1056 | + $post_type = 'Events'; |
|
1057 | + } |
|
1058 | + echo wp_kses_post( ' <span class="label label-default lsx-label-post-type">' . $post_type . '</span>' ); |
|
1059 | + } |
|
1060 | + } |
|
1061 | + } |
|
1062 | + |
|
1063 | + /** |
|
1064 | + * Changes the sort options. |
|
1065 | + */ |
|
1066 | + public function facetwp_sort_options( $options, $params ) { |
|
1067 | + $this->set_vars(); |
|
1068 | + |
|
1069 | + if ( true === $this->search_enabled ) { |
|
1070 | + if ( 'default' !== $params['template_name'] && 'wp' !== $params['template_name'] ) { |
|
1071 | + return $options; |
|
1072 | + } |
|
1073 | + |
|
1074 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_date' ] ) ) { |
|
1075 | + unset( $options['date_desc'] ); |
|
1076 | + unset( $options['date_asc'] ); |
|
1077 | + } |
|
1078 | + |
|
1079 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_az_sorting' ] ) ) { |
|
1080 | + unset( $options['title_desc'] ); |
|
1081 | + unset( $options['title_asc'] ); |
|
1082 | + } |
|
1083 | + } |
|
1084 | + |
|
1085 | + return $options; |
|
1086 | + } |
|
1087 | + |
|
1088 | + /** |
|
1089 | + * @param $allowedtags |
|
1090 | + * @param $context |
|
1091 | + * |
|
1092 | + * @return mixed |
|
1093 | + */ |
|
1094 | + public function kses_allowed_html( $allowedtags, $context ) { |
|
1095 | + $allowedtags['a']['data-value'] = true; |
|
1096 | + $allowedtags['a']['data-selection'] = true; |
|
1097 | + $allowedtags['button']['data-toggle'] = true; |
|
1098 | + return $allowedtags; |
|
1099 | + } |
|
1100 | + |
|
1101 | + /** |
|
1102 | + * Change FaceWP result count HTML |
|
1103 | + */ |
|
1104 | + public function get_search_query( $keyword ) { |
|
1105 | + global $wp_rewrite,$wp_query; |
|
1106 | + |
|
1107 | + if ( empty( $keyword ) ) { |
|
1108 | + if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
1109 | + return; |
|
1110 | + } |
|
1111 | + $search_base = $wp_rewrite->search_base; |
|
1112 | + if ( strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) !== false ) { |
|
1113 | + $words = explode( "/{$search_base}/", $_SERVER['REQUEST_URI'] ); |
|
1114 | + $limit = count( $words ); |
|
1115 | + if ( isset( $words[ $limit - 1 ] ) ) { |
|
1116 | + $keyword = $words[ $limit - 1 ]; |
|
1117 | + } |
|
1118 | + } |
|
1119 | + } |
|
1120 | + |
|
1121 | + $needle = trim( '/ ' ); |
|
1122 | + $words = explode( $needle, $keyword ); |
|
1123 | + if ( is_array( $words ) && ! empty( $words ) ) { |
|
1124 | + $keyword = $words[ count( $words ) - 1 ]; |
|
1125 | + } |
|
1126 | + $keyword = str_replace( '+', ' ', $keyword ); |
|
1127 | + return $keyword; |
|
1128 | + } |
|
1129 | 1129 | } |
@@ -70,28 +70,28 @@ discard block |
||
70 | 70 | $this->options = \lsx\search\includes\get_options(); |
71 | 71 | $this->load_classes(); |
72 | 72 | |
73 | - add_filter( 'wpseo_json_ld_search_url', array( $this, 'change_json_ld_search_url' ), 10, 1 ); |
|
74 | - add_action( 'wp', array( $this, 'set_vars' ), 21 ); |
|
75 | - add_action( 'wp', array( $this, 'set_facetwp_vars' ), 22 ); |
|
76 | - add_action( 'wp', array( $this, 'core' ), 23 ); |
|
77 | - add_action( 'lsx_body_top', array( $this, 'check_for_results' ) ); |
|
78 | - |
|
79 | - add_filter( 'pre_get_posts', array( $this, 'ignore_sticky_search' ) ); |
|
80 | - add_action( 'pre_get_posts', array( $this, 'filter_post_types' ) ); |
|
81 | - |
|
82 | - add_filter( 'lsx_search_post_types', array( $this, 'register_post_types' ) ); |
|
83 | - add_filter( 'lsx_search_taxonomies', array( $this, 'register_taxonomies' ) ); |
|
84 | - add_filter( 'lsx_search_post_types_plural', array( $this, 'register_post_type_tabs' ) ); |
|
85 | - add_filter( 'facetwp_sort_options', array( $this, 'facetwp_sort_options' ), 10, 2 ); |
|
86 | - add_filter( 'wp_kses_allowed_html', array( $this, 'kses_allowed_html' ), 20, 2 ); |
|
87 | - add_filter( 'get_search_query', array( $this, 'get_search_query' ) ); |
|
73 | + add_filter('wpseo_json_ld_search_url', array($this, 'change_json_ld_search_url'), 10, 1); |
|
74 | + add_action('wp', array($this, 'set_vars'), 21); |
|
75 | + add_action('wp', array($this, 'set_facetwp_vars'), 22); |
|
76 | + add_action('wp', array($this, 'core'), 23); |
|
77 | + add_action('lsx_body_top', array($this, 'check_for_results')); |
|
78 | + |
|
79 | + add_filter('pre_get_posts', array($this, 'ignore_sticky_search')); |
|
80 | + add_action('pre_get_posts', array($this, 'filter_post_types')); |
|
81 | + |
|
82 | + add_filter('lsx_search_post_types', array($this, 'register_post_types')); |
|
83 | + add_filter('lsx_search_taxonomies', array($this, 'register_taxonomies')); |
|
84 | + add_filter('lsx_search_post_types_plural', array($this, 'register_post_type_tabs')); |
|
85 | + add_filter('facetwp_sort_options', array($this, 'facetwp_sort_options'), 10, 2); |
|
86 | + add_filter('wp_kses_allowed_html', array($this, 'kses_allowed_html'), 20, 2); |
|
87 | + add_filter('get_search_query', array($this, 'get_search_query')); |
|
88 | 88 | |
89 | 89 | // Redirects. |
90 | - add_action( 'template_redirect', array( $this, 'pretty_search_redirect' ) ); |
|
91 | - add_filter( 'pre_get_posts', array( $this, 'pretty_search_parse_query' ) ); |
|
90 | + add_action('template_redirect', array($this, 'pretty_search_redirect')); |
|
91 | + add_filter('pre_get_posts', array($this, 'pretty_search_parse_query')); |
|
92 | 92 | |
93 | - add_action( 'lsx_search_sidebar_top', array( $this, 'search_sidebar_top' ) ); |
|
94 | - add_filter( 'facetwp_facet_html', array( $this, 'search_facet_html' ), 10, 2 ); |
|
93 | + add_action('lsx_search_sidebar_top', array($this, 'search_sidebar_top')); |
|
94 | + add_filter('facetwp_facet_html', array($this, 'search_facet_html'), 10, 2); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public static function get_instance() { |
105 | 105 | // If the single instance hasn't been set, set it now. |
106 | - if ( null === self::$instance ) { |
|
106 | + if (null === self::$instance) { |
|
107 | 107 | self::$instance = new self(); |
108 | 108 | } |
109 | 109 | return self::$instance; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * Loads the variable classes and the static classes. |
114 | 114 | */ |
115 | 115 | private function load_classes() { |
116 | - require_once LSX_SEARCH_PATH . 'classes/frontend/class-layout.php'; |
|
116 | + require_once LSX_SEARCH_PATH.'classes/frontend/class-layout.php'; |
|
117 | 117 | $this->layout = frontend\Layout::get_instance(); |
118 | 118 | } |
119 | 119 | |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | public function set_vars() { |
124 | 124 | $post_type = ''; |
125 | 125 | |
126 | - $this->post_types = apply_filters( 'lsx_search_post_types', array() ); |
|
127 | - $this->taxonomies = apply_filters( 'lsx_search_taxonomies', array() ); |
|
128 | - $this->tabs = apply_filters( 'lsx_search_post_types_plural', array() ); |
|
129 | - $this->options = apply_filters( 'lsx_search_options', $this->options ); |
|
126 | + $this->post_types = apply_filters('lsx_search_post_types', array()); |
|
127 | + $this->taxonomies = apply_filters('lsx_search_taxonomies', array()); |
|
128 | + $this->tabs = apply_filters('lsx_search_post_types_plural', array()); |
|
129 | + $this->options = apply_filters('lsx_search_options', $this->options); |
|
130 | 130 | $this->post_types = get_post_types(); |
131 | 131 | $this->post_type_slugs = array( |
132 | 132 | 'post' => 'posts', |
@@ -139,22 +139,22 @@ discard block |
||
139 | 139 | ); |
140 | 140 | $this->set_search_prefix(); |
141 | 141 | $this->get_cmb2_options(); |
142 | - $this->search_enabled = apply_filters( 'lsx_search_enabled', $this->is_search_enabled(), $this ); |
|
143 | - $this->search_prefix = apply_filters( 'lsx_search_prefix', $this->search_prefix, $this ); |
|
142 | + $this->search_enabled = apply_filters('lsx_search_enabled', $this->is_search_enabled(), $this); |
|
143 | + $this->search_prefix = apply_filters('lsx_search_prefix', $this->search_prefix, $this); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | private function get_cmb2_options() { |
147 | - $cmb2_options = get_option( 'lsx-search-settings' ); |
|
148 | - if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
149 | - $this->set_search_prefix( true ); |
|
147 | + $cmb2_options = get_option('lsx-search-settings'); |
|
148 | + if (false !== $cmb2_options && !empty($cmb2_options)) { |
|
149 | + $this->set_search_prefix(true); |
|
150 | 150 | $this->options['display'] = $cmb2_options; |
151 | - foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
152 | - if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
151 | + foreach ($this->options['display'] as $option_key => $option_value) { |
|
152 | + if (is_array($option_value) && !empty($option_value)) { |
|
153 | 153 | $new_values = array(); |
154 | - foreach ( $option_value as $empty_key => $key_value ) { |
|
155 | - $new_values[ $key_value ] = 'on'; |
|
154 | + foreach ($option_value as $empty_key => $key_value) { |
|
155 | + $new_values[$key_value] = 'on'; |
|
156 | 156 | } |
157 | - $this->options['display'][ $option_key ] = $new_values; |
|
157 | + $this->options['display'][$option_key] = $new_values; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | $this->new_options = true; |
@@ -164,46 +164,46 @@ discard block |
||
164 | 164 | |
165 | 165 | private function disable_to_search_actions() { |
166 | 166 | global $lsx_to_search_fwp, $lsx_to_search; |
167 | - if ( null !== $lsx_to_search ) { |
|
167 | + if (null !== $lsx_to_search) { |
|
168 | 168 | // Redirects. |
169 | - remove_filter( 'template_include', array( $lsx_to_search, 'search_template_include' ), 99 ); |
|
170 | - remove_action( 'template_redirect', array( $lsx_to_search, 'pretty_search_redirect' ) ); |
|
171 | - remove_filter( 'pre_get_posts', array( $lsx_to_search, 'pretty_search_parse_query' ) ); |
|
169 | + remove_filter('template_include', array($lsx_to_search, 'search_template_include'), 99); |
|
170 | + remove_action('template_redirect', array($lsx_to_search, 'pretty_search_redirect')); |
|
171 | + remove_filter('pre_get_posts', array($lsx_to_search, 'pretty_search_parse_query')); |
|
172 | 172 | |
173 | 173 | // Layout Filter. |
174 | - remove_filter( 'lsx_layout', array( $lsx_to_search, 'lsx_layout' ), 20, 1 ); |
|
175 | - remove_filter( 'lsx_layout_selector', array( $lsx_to_search, 'lsx_layout_selector' ), 10, 4 ); |
|
176 | - remove_filter( 'lsx_to_archive_layout', array( $lsx_to_search, 'lsx_to_search_archive_layout' ), 10, 2 ); |
|
174 | + remove_filter('lsx_layout', array($lsx_to_search, 'lsx_layout'), 20, 1); |
|
175 | + remove_filter('lsx_layout_selector', array($lsx_to_search, 'lsx_layout_selector'), 10, 4); |
|
176 | + remove_filter('lsx_to_archive_layout', array($lsx_to_search, 'lsx_to_search_archive_layout'), 10, 2); |
|
177 | 177 | |
178 | - remove_action( 'lsx_search_sidebar_top', array( $lsx_to_search, 'search_sidebar_top' ) ); |
|
179 | - remove_action( 'pre_get_posts', array( $lsx_to_search, 'price_sorting' ), 100 ); |
|
178 | + remove_action('lsx_search_sidebar_top', array($lsx_to_search, 'search_sidebar_top')); |
|
179 | + remove_action('pre_get_posts', array($lsx_to_search, 'price_sorting'), 100); |
|
180 | 180 | |
181 | 181 | //add_shortcode( 'lsx_search_form', array( 'LSX_TO_Search_Frontend', 'search_form' ) ); |
182 | - remove_filter( 'searchwp_short_circuit', array( $lsx_to_search, 'searchwp_short_circuit' ), 10, 2 ); |
|
183 | - remove_filter( 'get_search_query', array( $lsx_to_search, 'get_search_query' ) ); |
|
184 | - remove_filter( 'body_class', array( $lsx_to_search, 'to_add_search_url_class' ), 20 ); |
|
182 | + remove_filter('searchwp_short_circuit', array($lsx_to_search, 'searchwp_short_circuit'), 10, 2); |
|
183 | + remove_filter('get_search_query', array($lsx_to_search, 'get_search_query')); |
|
184 | + remove_filter('body_class', array($lsx_to_search, 'to_add_search_url_class'), 20); |
|
185 | 185 | |
186 | - remove_filter( 'facetwp_preload_url_vars', array( $lsx_to_search, 'preload_url_vars' ), 10, 1 ); |
|
187 | - remove_filter( 'wpseo_json_ld_search_url', array( $lsx_to_search, 'change_json_ld_search_url' ), 10, 1 ); |
|
186 | + remove_filter('facetwp_preload_url_vars', array($lsx_to_search, 'preload_url_vars'), 10, 1); |
|
187 | + remove_filter('wpseo_json_ld_search_url', array($lsx_to_search, 'change_json_ld_search_url'), 10, 1); |
|
188 | 188 | } |
189 | - if ( null !== $lsx_to_search_fwp ) { |
|
190 | - remove_filter( 'facetwp_indexer_row_data', array( $lsx_to_search_fwp, 'facetwp_index_row_data' ), 10, 2 ); |
|
191 | - remove_filter( 'facetwp_index_row', array( $lsx_to_search_fwp, 'facetwp_index_row' ), 10, 2 ); |
|
189 | + if (null !== $lsx_to_search_fwp) { |
|
190 | + remove_filter('facetwp_indexer_row_data', array($lsx_to_search_fwp, 'facetwp_index_row_data'), 10, 2); |
|
191 | + remove_filter('facetwp_index_row', array($lsx_to_search_fwp, 'facetwp_index_row'), 10, 2); |
|
192 | 192 | |
193 | - remove_filter( 'facetwp_sort_options', array( $lsx_to_search_fwp, 'facet_sort_options' ), 10, 2 ); |
|
193 | + remove_filter('facetwp_sort_options', array($lsx_to_search_fwp, 'facet_sort_options'), 10, 2); |
|
194 | 194 | |
195 | - remove_filter( 'facetwp_pager_html', array( $lsx_to_search_fwp, 'facetwp_pager_html' ), 10, 2 ); |
|
196 | - remove_filter( 'facetwp_result_count', array( $lsx_to_search_fwp, 'facetwp_result_count' ), 10, 2 ); |
|
195 | + remove_filter('facetwp_pager_html', array($lsx_to_search_fwp, 'facetwp_pager_html'), 10, 2); |
|
196 | + remove_filter('facetwp_result_count', array($lsx_to_search_fwp, 'facetwp_result_count'), 10, 2); |
|
197 | 197 | |
198 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'destination_facet_html' ), 10, 2 ); |
|
199 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'slide_facet_html' ), 10, 2 ); |
|
200 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'search_facet_html' ), 10, 2 ); |
|
201 | - remove_filter( 'facetwp_load_css', array( $lsx_to_search_fwp, 'facetwp_load_css' ), 10, 1 ); |
|
198 | + remove_filter('facetwp_facet_html', array($lsx_to_search_fwp, 'destination_facet_html'), 10, 2); |
|
199 | + remove_filter('facetwp_facet_html', array($lsx_to_search_fwp, 'slide_facet_html'), 10, 2); |
|
200 | + remove_filter('facetwp_facet_html', array($lsx_to_search_fwp, 'search_facet_html'), 10, 2); |
|
201 | + remove_filter('facetwp_load_css', array($lsx_to_search_fwp, 'facetwp_load_css'), 10, 1); |
|
202 | 202 | |
203 | - if ( class_exists( 'LSX_Currencies' ) ) { |
|
204 | - remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_lsx_currencies' ), 10, 2 ); |
|
203 | + if (class_exists('LSX_Currencies')) { |
|
204 | + remove_filter('facetwp_render_output', array($lsx_to_search_fwp, 'slide_price_lsx_currencies'), 10, 2); |
|
205 | 205 | } else { |
206 | - remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_to_currencies' ), 10, 2 ); |
|
206 | + remove_filter('facetwp_render_output', array($lsx_to_search_fwp, 'slide_price_to_currencies'), 10, 2); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
@@ -216,19 +216,19 @@ discard block |
||
216 | 216 | public function is_search_enabled() { |
217 | 217 | $search_enabled = false; |
218 | 218 | |
219 | - if ( false === $this->new_options ) { |
|
220 | - if ( isset( $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) && ( ! empty( $this->options ) ) && 'on' == $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) { |
|
219 | + if (false === $this->new_options) { |
|
220 | + if (isset($this->options['display'][$this->search_prefix.'_enable_'.$this->search_core_suffix]) && (!empty($this->options)) && 'on' == $this->options['display'][$this->search_prefix.'_enable_'.$this->search_core_suffix]) { |
|
221 | 221 | $search_enabled = true; |
222 | 222 | } |
223 | 223 | } else { |
224 | 224 | $enable_prefix = $this->search_prefix; |
225 | - if ( ! empty( $this->options ) && isset( $this->options['display'] ) && isset( $this->options['display'][ $enable_prefix . '_enable' ] ) && 'on' === $this->options['display'][ $enable_prefix . '_enable' ] ) { |
|
225 | + if (!empty($this->options) && isset($this->options['display']) && isset($this->options['display'][$enable_prefix.'_enable']) && 'on' === $this->options['display'][$enable_prefix.'_enable']) { |
|
226 | 226 | $search_enabled = true; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | 230 | // These are specific plugin exclusions. |
231 | - if ( is_tax( array( 'wcpv_product_vendors' ) ) ) { |
|
231 | + if (is_tax(array('wcpv_product_vendors'))) { |
|
232 | 232 | $search_enabled = false; |
233 | 233 | } |
234 | 234 | return $search_enabled; |
@@ -239,44 +239,44 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return void |
241 | 241 | */ |
242 | - private function set_search_prefix( $new_prefixes = false ) { |
|
243 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
244 | - if ( false !== $new_prefixes ) { |
|
242 | + private function set_search_prefix($new_prefixes = false) { |
|
243 | + $page_for_posts = get_option('page_for_posts'); |
|
244 | + if (false !== $new_prefixes) { |
|
245 | 245 | $this->taxonomies = array(); |
246 | 246 | $this->post_types = array(); |
247 | 247 | } |
248 | 248 | |
249 | - if ( is_search() ) { |
|
250 | - if ( false === $new_prefixes ) { |
|
249 | + if (is_search()) { |
|
250 | + if (false === $new_prefixes) { |
|
251 | 251 | $this->search_core_suffix = 'core'; |
252 | 252 | $this->search_prefix = 'search'; |
253 | 253 | } else { |
254 | 254 | $this->search_core_suffix = 'enable'; |
255 | 255 | $this->search_prefix = 'engine_search'; |
256 | 256 | } |
257 | - } elseif ( is_post_type_archive( $this->post_types ) || is_tax() || is_page( $page_for_posts ) || is_home() || is_category() || is_tag() ) { |
|
258 | - if ( false === $new_prefixes ) { |
|
257 | + } elseif (is_post_type_archive($this->post_types) || is_tax() || is_page($page_for_posts) || is_home() || is_category() || is_tag()) { |
|
258 | + if (false === $new_prefixes) { |
|
259 | 259 | $this->search_core_suffix = 'search'; |
260 | 260 | } else { |
261 | 261 | $this->search_core_suffix = 'enable'; |
262 | 262 | } |
263 | 263 | |
264 | - if ( is_tax() ) { |
|
265 | - $tax = get_query_var( 'taxonomy' ); |
|
266 | - $tax = get_taxonomy( $tax ); |
|
264 | + if (is_tax()) { |
|
265 | + $tax = get_query_var('taxonomy'); |
|
266 | + $tax = get_taxonomy($tax); |
|
267 | 267 | $post_type = $tax->object_type[0]; |
268 | - } else if ( is_page( $page_for_posts ) || is_category() || is_tag() || is_home() ) { |
|
268 | + } else if (is_page($page_for_posts) || is_category() || is_tag() || is_home()) { |
|
269 | 269 | $post_type = 'post'; |
270 | 270 | } else { |
271 | - $post_type = get_query_var( 'post_type' ); |
|
271 | + $post_type = get_query_var('post_type'); |
|
272 | 272 | } |
273 | 273 | |
274 | - if ( false === $new_prefixes ) { |
|
275 | - if ( isset( $this->tabs[ $post_type ] ) ) { |
|
276 | - $this->search_prefix = $this->tabs[ $post_type ] . '_archive'; |
|
274 | + if (false === $new_prefixes) { |
|
275 | + if (isset($this->tabs[$post_type])) { |
|
276 | + $this->search_prefix = $this->tabs[$post_type].'_archive'; |
|
277 | 277 | } |
278 | 278 | } else { |
279 | - $this->search_prefix = $post_type . '_search'; |
|
279 | + $this->search_prefix = $post_type.'_search'; |
|
280 | 280 | } |
281 | 281 | } |
282 | 282 | } |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function set_facetwp_vars() { |
288 | 288 | |
289 | - if ( class_exists( 'FacetWP' ) ) { |
|
289 | + if (class_exists('FacetWP')) { |
|
290 | 290 | $facet_data = FWP()->helper->get_facets(); |
291 | 291 | } |
292 | 292 | |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | |
295 | 295 | $this->facet_data['search_form'] = array( |
296 | 296 | 'name' => 'search_form', |
297 | - 'label' => esc_html__( 'Search Form', 'lsx-search' ), |
|
297 | + 'label' => esc_html__('Search Form', 'lsx-search'), |
|
298 | 298 | ); |
299 | 299 | |
300 | - if ( ! empty( $facet_data ) && is_array( $facet_data ) ) { |
|
301 | - foreach ( $facet_data as $facet ) { |
|
302 | - $this->facet_data[ $facet['name'] ] = $facet; |
|
300 | + if (!empty($facet_data) && is_array($facet_data)) { |
|
301 | + foreach ($facet_data as $facet) { |
|
302 | + $this->facet_data[$facet['name']] = $facet; |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | } |
@@ -309,61 +309,61 @@ discard block |
||
309 | 309 | */ |
310 | 310 | public function core() { |
311 | 311 | |
312 | - if ( true === $this->search_enabled ) { |
|
313 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 999 ); |
|
312 | + if (true === $this->search_enabled) { |
|
313 | + add_action('wp_enqueue_scripts', array($this, 'assets'), 999); |
|
314 | 314 | |
315 | - add_filter( 'lsx_layout', array( $this, 'lsx_layout' ), 20, 1 ); |
|
316 | - add_filter( 'lsx_layout_selector', array( $this, 'lsx_layout_selector' ), 10, 4 ); |
|
317 | - add_filter( 'lsx_slot_class', array( $this, 'change_slot_column_class' ) ); |
|
318 | - add_action( 'lsx_entry_top', array( $this, 'add_label_to_title' ) ); |
|
319 | - add_filter( 'body_class', array( $this, 'body_class' ), 10 ); |
|
315 | + add_filter('lsx_layout', array($this, 'lsx_layout'), 20, 1); |
|
316 | + add_filter('lsx_layout_selector', array($this, 'lsx_layout_selector'), 10, 4); |
|
317 | + add_filter('lsx_slot_class', array($this, 'change_slot_column_class')); |
|
318 | + add_action('lsx_entry_top', array($this, 'add_label_to_title')); |
|
319 | + add_filter('body_class', array($this, 'body_class'), 10); |
|
320 | 320 | |
321 | - add_filter( 'lsx_blog_customizer_top_of_blog_action', array( $this, 'top_of_blog_action' ), 10, 1 ); |
|
322 | - add_filter( 'lsx_blog_customizer_blog_description_class', array( $this, 'blog_description_class' ), 10, 1 ); |
|
321 | + add_filter('lsx_blog_customizer_top_of_blog_action', array($this, 'top_of_blog_action'), 10, 1); |
|
322 | + add_filter('lsx_blog_customizer_blog_description_class', array($this, 'blog_description_class'), 10, 1); |
|
323 | 323 | |
324 | - if ( class_exists( 'LSX_Videos' ) ) { |
|
324 | + if (class_exists('LSX_Videos')) { |
|
325 | 325 | global $lsx_videos_frontend; |
326 | - remove_action( 'lsx_content_top', array( $lsx_videos_frontend, 'categories_tabs' ), 15 ); |
|
326 | + remove_action('lsx_content_top', array($lsx_videos_frontend, 'categories_tabs'), 15); |
|
327 | 327 | } |
328 | 328 | |
329 | - add_filter( 'lsx_paging_nav_disable', '__return_true' ); |
|
330 | - add_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
331 | - add_action( 'lsx_content_top', array( $this, 'facetwp_tempate_open' ) ); |
|
332 | - add_action( 'lsx_content_bottom', array( $this, 'facetwp_tempate_close' ) ); |
|
333 | - add_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
329 | + add_filter('lsx_paging_nav_disable', '__return_true'); |
|
330 | + add_action('lsx_content_top', array($this, 'facet_top_bar')); |
|
331 | + add_action('lsx_content_top', array($this, 'facetwp_tempate_open')); |
|
332 | + add_action('lsx_content_bottom', array($this, 'facetwp_tempate_close')); |
|
333 | + add_action('lsx_content_bottom', array($this, 'facet_bottom_bar')); |
|
334 | 334 | |
335 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) && '1c' !== $this->options['display'][ $this->search_prefix . '_layout' ] ) { |
|
336 | - add_filter( 'lsx_sidebar_enable', array( $this, 'lsx_sidebar_enable' ), 10, 1 ); |
|
335 | + if (!empty($this->options['display'][$this->search_prefix.'_layout']) && '1c' !== $this->options['display'][$this->search_prefix.'_layout']) { |
|
336 | + add_filter('lsx_sidebar_enable', array($this, 'lsx_sidebar_enable'), 10, 1); |
|
337 | 337 | } |
338 | 338 | |
339 | - add_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
339 | + add_action('lsx_content_wrap_before', array($this, 'search_sidebar'), 150); |
|
340 | 340 | |
341 | - if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) { |
|
342 | - remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' ); |
|
343 | - remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' ); |
|
344 | - add_filter( 'woocommerce_show_page_title', '__return_false' ); |
|
341 | + if (class_exists('WooCommerce') && (is_shop() || is_product_category() || is_product_tag())) { |
|
342 | + remove_action('woocommerce_archive_description', 'woocommerce_taxonomy_archive_description'); |
|
343 | + remove_action('woocommerce_archive_description', 'woocommerce_product_archive_description'); |
|
344 | + add_filter('woocommerce_show_page_title', '__return_false'); |
|
345 | 345 | |
346 | - add_filter( 'loop_shop_columns', function() { |
|
346 | + add_filter('loop_shop_columns', function() { |
|
347 | 347 | return 3; |
348 | 348 | } ); |
349 | 349 | |
350 | 350 | // Actions added by LSX theme |
351 | - remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
|
352 | - add_action( 'lsx_content_wrap_before', array( $this, 'wc_archive_header' ), 140 ); |
|
351 | + remove_action('lsx_content_wrap_before', 'lsx_global_header'); |
|
352 | + add_action('lsx_content_wrap_before', array($this, 'wc_archive_header'), 140); |
|
353 | 353 | |
354 | 354 | // Actions added be LSX theme / woocommerce.php file |
355 | - remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
356 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
357 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 ); |
|
358 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 ); |
|
359 | - remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
355 | + remove_action('woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9); |
|
356 | + remove_action('woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10); |
|
357 | + remove_action('woocommerce_after_shop_loop', 'woocommerce_result_count', 20); |
|
358 | + remove_action('woocommerce_after_shop_loop', 'woocommerce_pagination', 30); |
|
359 | + remove_action('woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31); |
|
360 | 360 | |
361 | 361 | // Actions added be LSX theme / woocommerce.php file |
362 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
363 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
364 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
365 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 ); |
|
366 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
362 | + remove_action('woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9); |
|
363 | + remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10); |
|
364 | + remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20); |
|
365 | + remove_action('woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30); |
|
366 | + remove_action('woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | * @param array $classes The classes. |
375 | 375 | * @return array $classes The classes. |
376 | 376 | */ |
377 | - public function body_class( $classes ) { |
|
377 | + public function body_class($classes) { |
|
378 | 378 | $classes[] = 'lsx-search-enabled'; |
379 | 379 | return $classes; |
380 | 380 | } |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * @param string $action |
386 | 386 | * @return string $action |
387 | 387 | */ |
388 | - public function top_of_blog_action( $action = '' ) { |
|
388 | + public function top_of_blog_action($action = '') { |
|
389 | 389 | $action = 'lsx_content_wrap_before'; |
390 | 390 | return $action; |
391 | 391 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @param string $action |
397 | 397 | * @return string $action |
398 | 398 | */ |
399 | - public function blog_description_class( $class = '' ) { |
|
399 | + public function blog_description_class($class = '') { |
|
400 | 400 | $class .= ' col-md-12 search-description'; |
401 | 401 | return $class; |
402 | 402 | } |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | * @return void |
408 | 408 | */ |
409 | 409 | public function check_for_results() { |
410 | - if ( true === $this->search_enabled ) { |
|
410 | + if (true === $this->search_enabled) { |
|
411 | 411 | global $wp_query; |
412 | - if ( empty( $wp_query->posts ) ) { |
|
412 | + if (empty($wp_query->posts)) { |
|
413 | 413 | $this->has_posts = false; |
414 | - remove_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
415 | - remove_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
416 | - remove_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
414 | + remove_action('lsx_content_top', array($this, 'facet_top_bar')); |
|
415 | + remove_action('lsx_content_bottom', array($this, 'facet_bottom_bar')); |
|
416 | + remove_action('lsx_content_wrap_before', array($this, 'search_sidebar'), 150); |
|
417 | 417 | } else { |
418 | 418 | $this->has_posts = true; |
419 | 419 | } |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | /** |
424 | 424 | * Filter the post types. |
425 | 425 | */ |
426 | - public function filter_post_types( $query ) { |
|
427 | - if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { |
|
428 | - if ( ! empty( $this->options ) && ! empty( $this->options['display']['search_enable_core'] ) ) { |
|
429 | - if ( ! empty( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
430 | - $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
431 | - $query->set( 'post_type', $post_types ); |
|
426 | + public function filter_post_types($query) { |
|
427 | + if (!is_admin() && $query->is_main_query() && $query->is_search()) { |
|
428 | + if (!empty($this->options) && !empty($this->options['display']['search_enable_core'])) { |
|
429 | + if (!empty($this->options['general']['search_post_types']) && is_array($this->options['general']['search_post_types'])) { |
|
430 | + $post_types = array_keys($this->options['general']['search_post_types']); |
|
431 | + $query->set('post_type', $post_types); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | } |
@@ -437,23 +437,23 @@ discard block |
||
437 | 437 | /** |
438 | 438 | * Sets post types with active search options. |
439 | 439 | */ |
440 | - public function register_post_types( $post_types ) { |
|
441 | - $post_types = array( 'post', 'project', 'service', 'team', 'testimonial', 'video', 'product' ); |
|
440 | + public function register_post_types($post_types) { |
|
441 | + $post_types = array('post', 'project', 'service', 'team', 'testimonial', 'video', 'product'); |
|
442 | 442 | return $post_types; |
443 | 443 | } |
444 | 444 | |
445 | 445 | /** |
446 | 446 | * Sets taxonomies with active search options. |
447 | 447 | */ |
448 | - public function register_taxonomies( $taxonomies ) { |
|
449 | - $taxonomies = array( 'category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag' ); |
|
448 | + public function register_taxonomies($taxonomies) { |
|
449 | + $taxonomies = array('category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag'); |
|
450 | 450 | return $taxonomies; |
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
454 | 454 | * Sets post types with active search options. |
455 | 455 | */ |
456 | - public function register_post_type_tabs( $post_types_plural ) { |
|
456 | + public function register_post_type_tabs($post_types_plural) { |
|
457 | 457 | $post_types_plural = array( |
458 | 458 | 'post' => 'posts', |
459 | 459 | 'project' => 'projects', |
@@ -470,23 +470,23 @@ discard block |
||
470 | 470 | * Enqueue styles and scripts. |
471 | 471 | */ |
472 | 472 | public function assets() { |
473 | - add_filter( 'lsx_defer_parsing_of_js', array( $this, 'skip_js_defer' ), 10, 4 ); |
|
474 | - wp_enqueue_script( 'touchSwipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.touchSwipe.min.js', array( 'jquery' ), LSX_SEARCH_VER, true ); |
|
475 | - wp_enqueue_script( 'slideandswipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.slideandswipe.min.js', array( 'jquery', 'touchSwipe' ), LSX_SEARCH_VER, true ); |
|
476 | - wp_enqueue_script( 'lsx-search', LSX_SEARCH_URL . 'assets/js/src/lsx-search.js', array( 'jquery', 'touchSwipe', 'slideandswipe', 'jquery-ui-datepicker' ), LSX_SEARCH_VER, true ); |
|
473 | + add_filter('lsx_defer_parsing_of_js', array($this, 'skip_js_defer'), 10, 4); |
|
474 | + wp_enqueue_script('touchSwipe', LSX_SEARCH_URL.'assets/js/vendor/jquery.touchSwipe.min.js', array('jquery'), LSX_SEARCH_VER, true); |
|
475 | + wp_enqueue_script('slideandswipe', LSX_SEARCH_URL.'assets/js/vendor/jquery.slideandswipe.min.js', array('jquery', 'touchSwipe'), LSX_SEARCH_VER, true); |
|
476 | + wp_enqueue_script('lsx-search', LSX_SEARCH_URL.'assets/js/src/lsx-search.js', array('jquery', 'touchSwipe', 'slideandswipe', 'jquery-ui-datepicker'), LSX_SEARCH_VER, true); |
|
477 | 477 | |
478 | - $params = apply_filters( 'lsx_search_js_params', array( |
|
479 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
478 | + $params = apply_filters('lsx_search_js_params', array( |
|
479 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
480 | 480 | )); |
481 | 481 | |
482 | - wp_localize_script( 'lsx-search', 'lsx_customizer_params', $params ); |
|
482 | + wp_localize_script('lsx-search', 'lsx_customizer_params', $params); |
|
483 | 483 | |
484 | - wp_enqueue_style( 'lsx-search', LSX_SEARCH_URL . 'assets/css/lsx-search.css', array(), LSX_SEARCH_VER ); |
|
485 | - wp_style_add_data( 'lsx-search', 'rtl', 'replace' ); |
|
484 | + wp_enqueue_style('lsx-search', LSX_SEARCH_URL.'assets/css/lsx-search.css', array(), LSX_SEARCH_VER); |
|
485 | + wp_style_add_data('lsx-search', 'rtl', 'replace'); |
|
486 | 486 | |
487 | - if ( true === $this->new_options ) { |
|
488 | - wp_deregister_style( 'lsx_to_search' ); |
|
489 | - wp_deregister_script( 'lsx_to_search' ); |
|
487 | + if (true === $this->new_options) { |
|
488 | + wp_deregister_style('lsx_to_search'); |
|
489 | + wp_deregister_script('lsx_to_search'); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | * @param string $href |
500 | 500 | * @return boolean |
501 | 501 | */ |
502 | - public function skip_js_defer( $should_skip, $tag, $handle, $href ) { |
|
503 | - if ( ! is_admin() && ( false !== stripos( $href, 'lsx-search.min.js' ) || false !== stripos( $href, 'lsx-search.js' ) ) ) { |
|
502 | + public function skip_js_defer($should_skip, $tag, $handle, $href) { |
|
503 | + if (!is_admin() && (false !== stripos($href, 'lsx-search.min.js') || false !== stripos($href, 'lsx-search.js'))) { |
|
504 | 504 | $should_skip = true; |
505 | 505 | } |
506 | 506 | return $should_skip; |
@@ -512,10 +512,10 @@ discard block |
||
512 | 512 | * @param $template |
513 | 513 | * @return $template |
514 | 514 | */ |
515 | - public function search_template_include( $template ) { |
|
516 | - if ( is_main_query() && is_search() ) { |
|
517 | - if ( file_exists( LSX_SEARCH_PATH . 'templates/search.php' ) ) { |
|
518 | - $template = LSX_SEARCH_PATH . 'templates/search.php'; |
|
515 | + public function search_template_include($template) { |
|
516 | + if (is_main_query() && is_search()) { |
|
517 | + if (file_exists(LSX_SEARCH_PATH.'templates/search.php')) { |
|
518 | + $template = LSX_SEARCH_PATH.'templates/search.php'; |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | |
@@ -528,9 +528,9 @@ discard block |
||
528 | 528 | * @param [type] $query |
529 | 529 | * @return void |
530 | 530 | */ |
531 | - public function ignore_sticky_search( $query ) { |
|
532 | - if ( $query->is_main_query() && is_home() ) { |
|
533 | - $query->set( 'ignore_sticky_posts', true ); |
|
531 | + public function ignore_sticky_search($query) { |
|
532 | + if ($query->is_main_query() && is_home()) { |
|
533 | + $query->set('ignore_sticky_posts', true); |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | |
@@ -538,49 +538,49 @@ discard block |
||
538 | 538 | * Rewrite the search URL |
539 | 539 | */ |
540 | 540 | public function pretty_search_redirect() { |
541 | - global $wp_rewrite,$wp_query; |
|
541 | + global $wp_rewrite, $wp_query; |
|
542 | 542 | |
543 | - if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
543 | + if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { |
|
544 | 544 | return; |
545 | 545 | } |
546 | 546 | |
547 | 547 | $search_base = $wp_rewrite->search_base; |
548 | 548 | |
549 | - if ( is_search() && ! is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { |
|
550 | - $search_query = get_query_var( 's' ); |
|
551 | - if ( empty( $search_query ) && isset( $_GET['s'] ) ) { |
|
549 | + if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) { |
|
550 | + $search_query = get_query_var('s'); |
|
551 | + if (empty($search_query) && isset($_GET['s'])) { |
|
552 | 552 | $search_query = $_GET['s']; |
553 | 553 | } |
554 | 554 | $engine = ''; |
555 | 555 | |
556 | 556 | // If the search was triggered by a supplemental engine. |
557 | - if ( isset( $_GET['engine'] ) && 'default' !== $_GET['engine'] ) { |
|
558 | - $engine = sanitize_text_field( wp_unslash( $_GET['engine'] ) ); |
|
559 | - $index = array_search( $engine, $this->post_type_slugs, true ); |
|
560 | - if ( false !== $index ) { |
|
557 | + if (isset($_GET['engine']) && 'default' !== $_GET['engine']) { |
|
558 | + $engine = sanitize_text_field(wp_unslash($_GET['engine'])); |
|
559 | + $index = array_search($engine, $this->post_type_slugs, true); |
|
560 | + if (false !== $index) { |
|
561 | 561 | $engine = $index; |
562 | 562 | } |
563 | - $engine = $engine . '/'; |
|
563 | + $engine = $engine.'/'; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | $get_array = $_GET; |
567 | 567 | |
568 | - if ( is_array( $get_array ) && ! empty( $get_array ) ) { |
|
568 | + if (is_array($get_array) && !empty($get_array)) { |
|
569 | 569 | $vars_to_maintain = array(); |
570 | 570 | |
571 | - foreach ( $get_array as $ga_key => $ga_value ) { |
|
572 | - if ( false !== strpos( $ga_key, 'fwp_' ) ) { |
|
573 | - $vars_to_maintain[] = $ga_key . '=' . $ga_value; |
|
571 | + foreach ($get_array as $ga_key => $ga_value) { |
|
572 | + if (false !== strpos($ga_key, 'fwp_')) { |
|
573 | + $vars_to_maintain[] = $ga_key.'='.$ga_value; |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | } |
577 | 577 | |
578 | - $redirect_url = home_url( "/{$search_base}/" . $engine . urlencode( $search_query ) ); |
|
578 | + $redirect_url = home_url("/{$search_base}/".$engine.urlencode($search_query)); |
|
579 | 579 | |
580 | - if ( ! empty( $vars_to_maintain ) ) { |
|
581 | - $redirect_url .= '?' . implode( '&', $vars_to_maintain ); |
|
580 | + if (!empty($vars_to_maintain)) { |
|
581 | + $redirect_url .= '?'.implode('&', $vars_to_maintain); |
|
582 | 582 | } |
583 | - wp_redirect( $redirect_url ); |
|
583 | + wp_redirect($redirect_url); |
|
584 | 584 | exit(); |
585 | 585 | } |
586 | 586 | } |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | /** |
589 | 589 | * Parse the Query and trigger a search |
590 | 590 | */ |
591 | - public function pretty_search_parse_query( $query ) { |
|
591 | + public function pretty_search_parse_query($query) { |
|
592 | 592 | $this->post_type_slugs = array( |
593 | 593 | 'post' => 'posts', |
594 | 594 | 'project' => 'projects', |
@@ -598,26 +598,26 @@ discard block |
||
598 | 598 | 'video' => 'videos', |
599 | 599 | 'product' => 'products', // WooCommerce |
600 | 600 | ); |
601 | - if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) { |
|
602 | - $search_query = $query->get( 's' ); |
|
603 | - $keyword_test = explode( '/', $search_query ); |
|
601 | + if ($query->is_search() && !is_admin() && $query->is_main_query()) { |
|
602 | + $search_query = $query->get('s'); |
|
603 | + $keyword_test = explode('/', $search_query); |
|
604 | 604 | |
605 | - $index = array_search( $keyword_test[0], $this->post_type_slugs, true ); |
|
606 | - if ( false !== $index ) { |
|
607 | - $engine = $this->post_type_slugs[ $index ]; |
|
605 | + $index = array_search($keyword_test[0], $this->post_type_slugs, true); |
|
606 | + if (false !== $index) { |
|
607 | + $engine = $this->post_type_slugs[$index]; |
|
608 | 608 | |
609 | - $query->set( 'post_type', $engine ); |
|
610 | - $query->set( 'engine', $engine ); |
|
609 | + $query->set('post_type', $engine); |
|
610 | + $query->set('engine', $engine); |
|
611 | 611 | |
612 | - if ( count( $keyword_test ) > 1 ) { |
|
613 | - $query->set( 's', $keyword_test[1] ); |
|
614 | - } elseif ( post_type_exists( $engine ) ) { |
|
615 | - $query->set( 's', '' ); |
|
612 | + if (count($keyword_test) > 1) { |
|
613 | + $query->set('s', $keyword_test[1]); |
|
614 | + } elseif (post_type_exists($engine)) { |
|
615 | + $query->set('s', ''); |
|
616 | 616 | } |
617 | 617 | } else { |
618 | - if ( isset( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
619 | - $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
620 | - $query->set( 'post_type', $post_types ); |
|
618 | + if (isset($this->options['general']['search_post_types']) && is_array($this->options['general']['search_post_types'])) { |
|
619 | + $post_types = array_keys($this->options['general']['search_post_types']); |
|
620 | + $query->set('post_type', $post_types); |
|
621 | 621 | } |
622 | 622 | } |
623 | 623 | } |
@@ -630,18 +630,18 @@ discard block |
||
630 | 630 | * @return url |
631 | 631 | */ |
632 | 632 | public function change_json_ld_search_url() { |
633 | - return trailingslashit( home_url() ) . 'search/{search_term_string}'; |
|
633 | + return trailingslashit(home_url()).'search/{search_term_string}'; |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
637 | 637 | * A filter to set the layout to 2 column. |
638 | 638 | */ |
639 | - public function lsx_layout( $layout ) { |
|
640 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
641 | - if ( false === $this->has_posts ) { |
|
639 | + public function lsx_layout($layout) { |
|
640 | + if (!empty($this->options['display'][$this->search_prefix.'_layout'])) { |
|
641 | + if (false === $this->has_posts) { |
|
642 | 642 | $layout = '1c'; |
643 | 643 | } else { |
644 | - $layout = $this->options['display'][ $this->search_prefix . '_layout' ]; |
|
644 | + $layout = $this->options['display'][$this->search_prefix.'_layout']; |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | return $layout; |
@@ -651,23 +651,23 @@ discard block |
||
651 | 651 | * Outputs the Search Title Facet |
652 | 652 | */ |
653 | 653 | public function search_sidebar_top() { |
654 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) && true !== apply_filters( 'lsx_search_hide_search_box', false ) ) { |
|
654 | + if (!empty($this->options['display'][$this->search_prefix.'_facets']) && is_array($this->options['display'][$this->search_prefix.'_facets']) && true !== apply_filters('lsx_search_hide_search_box', false)) { |
|
655 | 655 | |
656 | - if ( ! is_search() ) { |
|
656 | + if (!is_search()) { |
|
657 | 657 | |
658 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
658 | + foreach ($this->options['display'][$this->search_prefix.'_facets'] as $facet => $facet_useless) { |
|
659 | 659 | |
660 | - if ( isset( $this->facet_data[ $facet ] ) && 'search' === $this->facet_data[ $facet ]['type'] ) { |
|
661 | - echo wp_kses_post( '<div class="row">' ); |
|
662 | - $this->display_facet_default( $facet ); |
|
663 | - echo wp_kses_post( '</div>' ); |
|
664 | - unset( $this->options['display'][ $this->search_prefix . '_facets' ][ $facet ] ); |
|
660 | + if (isset($this->facet_data[$facet]) && 'search' === $this->facet_data[$facet]['type']) { |
|
661 | + echo wp_kses_post('<div class="row">'); |
|
662 | + $this->display_facet_default($facet); |
|
663 | + echo wp_kses_post('</div>'); |
|
664 | + unset($this->options['display'][$this->search_prefix.'_facets'][$facet]); |
|
665 | 665 | } |
666 | 666 | } |
667 | 667 | } else { |
668 | - echo wp_kses_post( '<div class="row">' ); |
|
668 | + echo wp_kses_post('<div class="row">'); |
|
669 | 669 | $this->display_facet_search(); |
670 | - echo wp_kses_post( '</div>' ); |
|
670 | + echo wp_kses_post('</div>'); |
|
671 | 671 | } |
672 | 672 | } |
673 | 673 | } |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | * |
680 | 680 | * @return string |
681 | 681 | */ |
682 | - public function search_facet_html( $output, $params ) { |
|
683 | - if ( 'search' == $params['facet']['type'] ) { |
|
682 | + public function search_facet_html($output, $params) { |
|
683 | + if ('search' == $params['facet']['type']) { |
|
684 | 684 | |
685 | 685 | $value = (array) $params['selected_values']; |
686 | - $value = empty( $value ) ? '' : stripslashes( $value[0] ); |
|
687 | - $placeholder = isset( $params['facet']['placeholder'] ) ? $params['facet']['placeholder'] : __( 'Search...', 'lsx-search' ); |
|
688 | - $placeholder = facetwp_i18n( $placeholder ); |
|
686 | + $value = empty($value) ? '' : stripslashes($value[0]); |
|
687 | + $placeholder = isset($params['facet']['placeholder']) ? $params['facet']['placeholder'] : __('Search...', 'lsx-search'); |
|
688 | + $placeholder = facetwp_i18n($placeholder); |
|
689 | 689 | |
690 | 690 | ob_start(); |
691 | 691 | ?> |
@@ -693,11 +693,11 @@ discard block |
||
693 | 693 | <div class="search-form lsx-search-form 2"> |
694 | 694 | <div class="input-group facetwp-search-wrap"> |
695 | 695 | <div class="field"> |
696 | - <input class="facetwp-search search-field form-control" type="text" placeholder="<?php echo esc_attr( $placeholder ); ?>" autocomplete="off" value="<?php echo esc_attr( $value ); ?>"> |
|
696 | + <input class="facetwp-search search-field form-control" type="text" placeholder="<?php echo esc_attr($placeholder); ?>" autocomplete="off" value="<?php echo esc_attr($value); ?>"> |
|
697 | 697 | </div> |
698 | 698 | |
699 | 699 | <div class="field submit-button"> |
700 | - <button class="search-submit btn facetwp-btn" type="submit"><?php esc_html_e( 'Search', 'lsx-search' ); ?></button> |
|
700 | + <button class="search-submit btn facetwp-btn" type="submit"><?php esc_html_e('Search', 'lsx-search'); ?></button> |
|
701 | 701 | </div> |
702 | 702 | </div> |
703 | 703 | </div> |
@@ -711,23 +711,23 @@ discard block |
||
711 | 711 | /** |
712 | 712 | * Change the primary and secondary column classes. |
713 | 713 | */ |
714 | - public function lsx_layout_selector( $return_class, $class, $layout, $size ) { |
|
715 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
714 | + public function lsx_layout_selector($return_class, $class, $layout, $size) { |
|
715 | + if (!empty($this->options['display'][$this->search_prefix.'_layout'])) { |
|
716 | 716 | |
717 | - if ( '2cl' === $layout || '2cr' === $layout ) { |
|
717 | + if ('2cl' === $layout || '2cr' === $layout) { |
|
718 | 718 | $main_class = 'col-sm-8 col-md-9'; |
719 | 719 | $sidebar_class = 'col-sm-4 col-md-3'; |
720 | 720 | |
721 | - if ( '2cl' === $layout ) { |
|
721 | + if ('2cl' === $layout) { |
|
722 | 722 | $main_class .= ' col-sm-pull-4 col-md-pull-3 search-sidebar-left'; |
723 | 723 | $sidebar_class .= ' col-sm-push-8 col-md-push-9'; |
724 | 724 | } |
725 | 725 | |
726 | - if ( 'main' === $class ) { |
|
726 | + if ('main' === $class) { |
|
727 | 727 | return $main_class; |
728 | 728 | } |
729 | 729 | |
730 | - if ( 'sidebar' === $class ) { |
|
730 | + if ('sidebar' === $class) { |
|
731 | 731 | return $sidebar_class; |
732 | 732 | } |
733 | 733 | } |
@@ -742,14 +742,14 @@ discard block |
||
742 | 742 | * @return void |
743 | 743 | */ |
744 | 744 | public function display_alphabet_facet() { |
745 | - if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
746 | - $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
745 | + if (isset($this->options['display'][$this->search_prefix.'_az_pagination'])) { |
|
746 | + $az_pagination = $this->options['display'][$this->search_prefix.'_az_pagination']; |
|
747 | 747 | } else { |
748 | 748 | $az_pagination = false; |
749 | 749 | } |
750 | - $az_pagination = apply_filters( 'lsx_search_top_az_pagination', $az_pagination ); |
|
751 | - if ( false !== $az_pagination && '' !== $az_pagination ) { |
|
752 | - echo do_shortcode( '[facetwp facet="' . $az_pagination . '"]' ); |
|
750 | + $az_pagination = apply_filters('lsx_search_top_az_pagination', $az_pagination); |
|
751 | + if (false !== $az_pagination && '' !== $az_pagination) { |
|
752 | + echo do_shortcode('[facetwp facet="'.$az_pagination.'"]'); |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | |
@@ -757,44 +757,44 @@ discard block |
||
757 | 757 | * Outputs top. |
758 | 758 | */ |
759 | 759 | public function facet_top_bar() { |
760 | - if ( true === apply_filters( 'lsx_search_hide_top_bar', false ) ) { |
|
760 | + if (true === apply_filters('lsx_search_hide_top_bar', false)) { |
|
761 | 761 | return; |
762 | 762 | } |
763 | 763 | |
764 | 764 | $show_pagination = true; |
765 | 765 | $pagination_visible = false; |
766 | - $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
767 | - $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_sorting' ] ); |
|
768 | - |
|
769 | - $show_pagination = apply_filters( 'lsx_search_top_show_pagination', $show_pagination ); |
|
770 | - $pagination_visible = apply_filters( 'lsx_search_top_pagination_visible', $pagination_visible ); |
|
771 | - $show_per_page_combo = apply_filters( 'lsx_search_top_show_per_page_combo', $show_per_page_combo ); |
|
772 | - $show_sort_combo = apply_filters( 'lsx_search_top_show_sort_combo', $show_sort_combo ); |
|
773 | - $facet_row_classes = apply_filters( 'lsx_search_top_facetwp_row_classes', '' ); |
|
766 | + $show_per_page_combo = empty($this->options['display'][$this->search_prefix.'_disable_per_page']); |
|
767 | + $show_sort_combo = empty($this->options['display'][$this->search_prefix.'_disable_sorting']); |
|
768 | + |
|
769 | + $show_pagination = apply_filters('lsx_search_top_show_pagination', $show_pagination); |
|
770 | + $pagination_visible = apply_filters('lsx_search_top_pagination_visible', $pagination_visible); |
|
771 | + $show_per_page_combo = apply_filters('lsx_search_top_show_per_page_combo', $show_per_page_combo); |
|
772 | + $show_sort_combo = apply_filters('lsx_search_top_show_sort_combo', $show_sort_combo); |
|
773 | + $facet_row_classes = apply_filters('lsx_search_top_facetwp_row_classes', ''); |
|
774 | 774 | ?> |
775 | 775 | <div id="facetwp-top"> |
776 | - <?php if ( $show_sort_combo || ( $show_pagination && $show_per_page_combo ) ) { ?> |
|
777 | - <div class="row facetwp-top-row-1 hidden-xs <?php echo esc_attr( $facet_row_classes ); ?>"> |
|
776 | + <?php if ($show_sort_combo || ($show_pagination && $show_per_page_combo)) { ?> |
|
777 | + <div class="row facetwp-top-row-1 hidden-xs <?php echo esc_attr($facet_row_classes); ?>"> |
|
778 | 778 | <div class="col-xs-12"> |
779 | 779 | |
780 | - <?php if ( ! empty( $this->options['display'][ $this->search_prefix . '_display_result_count' ] ) && false === apply_filters( 'lsx_search_hide_result_count', false ) ) { ?> |
|
780 | + <?php if (!empty($this->options['display'][$this->search_prefix.'_display_result_count']) && false === apply_filters('lsx_search_hide_result_count', false)) { ?> |
|
781 | 781 | <div class="row"> |
782 | 782 | <div class="col-md-12 facetwp-item facetwp-results"> |
783 | - <h3 class="lsx-search-title lsx-search-title-results"><?php esc_html_e( 'Results', 'lsx-search' ); ?> <?php echo '(' . do_shortcode( '[facetwp counts="true"]' ) . ') '; ?> |
|
784 | - <?php if ( false !== $this->options && isset( $this->options['display'] ) && ( ! empty( $this->options['display'][ $this->search_prefix . '_display_clear_button' ] ) ) && 'on' === $this->options['display'][ $this->search_prefix . '_display_clear_button' ] ) { ?> |
|
785 | - <span class="clear-facets hidden">- <a title="<?php esc_html_e( 'Clear the current search filters.', 'lsx-search' ); ?>" class="facetwp-results-clear" type="button" onclick="<?php echo esc_attr( apply_filters( 'lsx_search_clear_function', 'lsx_search.clearFacets(this);' ) ); ?>"><?php esc_html_e( 'Clear', 'lsx-search' ); ?></a></span> |
|
783 | + <h3 class="lsx-search-title lsx-search-title-results"><?php esc_html_e('Results', 'lsx-search'); ?> <?php echo '('.do_shortcode('[facetwp counts="true"]').') '; ?> |
|
784 | + <?php if (false !== $this->options && isset($this->options['display']) && (!empty($this->options['display'][$this->search_prefix.'_display_clear_button'])) && 'on' === $this->options['display'][$this->search_prefix.'_display_clear_button']) { ?> |
|
785 | + <span class="clear-facets hidden">- <a title="<?php esc_html_e('Clear the current search filters.', 'lsx-search'); ?>" class="facetwp-results-clear" type="button" onclick="<?php echo esc_attr(apply_filters('lsx_search_clear_function', 'lsx_search.clearFacets(this);')); ?>"><?php esc_html_e('Clear', 'lsx-search'); ?></a></span> |
|
786 | 786 | <?php } ?> |
787 | 787 | </h3> |
788 | 788 | </div> |
789 | 789 | </div> |
790 | 790 | <?php } ?> |
791 | 791 | |
792 | - <?php do_action( 'lsx_search_facetwp_top_row' ); ?> |
|
792 | + <?php do_action('lsx_search_facetwp_top_row'); ?> |
|
793 | 793 | |
794 | 794 | <?php $this->display_alphabet_facet(); ?> |
795 | 795 | |
796 | - <?php if ( $show_sort_combo ) { ?> |
|
797 | - <?php echo do_shortcode( '[facetwp sort="true"]' ); ?> |
|
796 | + <?php if ($show_sort_combo) { ?> |
|
797 | + <?php echo do_shortcode('[facetwp sort="true"]'); ?> |
|
798 | 798 | <?php } ?> |
799 | 799 | |
800 | 800 | </div> |
@@ -808,30 +808,30 @@ discard block |
||
808 | 808 | * Outputs bottom. |
809 | 809 | */ |
810 | 810 | public function facet_bottom_bar() { |
811 | - if ( true === apply_filters( 'lsx_search_hide_bottom_bar', false ) ) { |
|
811 | + if (true === apply_filters('lsx_search_hide_bottom_bar', false)) { |
|
812 | 812 | return; |
813 | 813 | } |
814 | 814 | $show_pagination = true; |
815 | 815 | $pagination_visible = false; |
816 | - if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
817 | - $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
816 | + if (isset($this->options['display'][$this->search_prefix.'_az_pagination'])) { |
|
817 | + $az_pagination = $this->options['display'][$this->search_prefix.'_az_pagination']; |
|
818 | 818 | } else { |
819 | 819 | $az_pagination = false; |
820 | 820 | } |
821 | 821 | |
822 | - $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
823 | - $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_search_disable_sorting' ] ); |
|
822 | + $show_per_page_combo = empty($this->options['display'][$this->search_prefix.'_disable_per_page']); |
|
823 | + $show_sort_combo = empty($this->options['display'][$this->search_prefix.'_search_disable_sorting']); |
|
824 | 824 | |
825 | - $show_pagination = apply_filters( 'lsx_search_bottom_show_pagination', $show_pagination ); |
|
826 | - $pagination_visible = apply_filters( 'lsx_search_bottom_pagination_visible', $pagination_visible ); |
|
827 | - $show_per_page_combo = apply_filters( 'lsx_search_bottom_show_per_page_combo', $show_per_page_combo ); |
|
828 | - $show_sort_combo = apply_filters( 'lsx_search_bottom_show_sort_combo', $show_sort_combo ); |
|
825 | + $show_pagination = apply_filters('lsx_search_bottom_show_pagination', $show_pagination); |
|
826 | + $pagination_visible = apply_filters('lsx_search_bottom_pagination_visible', $pagination_visible); |
|
827 | + $show_per_page_combo = apply_filters('lsx_search_bottom_show_per_page_combo', $show_per_page_combo); |
|
828 | + $show_sort_combo = apply_filters('lsx_search_bottom_show_sort_combo', $show_sort_combo); |
|
829 | 829 | |
830 | - if ( $show_pagination || ! empty( $az_pagination ) ) { ?> |
|
830 | + if ($show_pagination || !empty($az_pagination)) { ?> |
|
831 | 831 | <div id="facetwp-bottom"> |
832 | 832 | <div class="row facetwp-bottom-row-1"> |
833 | 833 | <div class="col-xs-12"> |
834 | - <?php do_action( 'lsx_search_facetwp_bottom_row' ); ?> |
|
834 | + <?php do_action('lsx_search_facetwp_bottom_row'); ?> |
|
835 | 835 | |
836 | 836 | <?php //if ( $show_sort_combo ) { ?> |
837 | 837 | <?php //echo do_shortcode( '[facetwp sort="true"]' ); ?> |
@@ -842,16 +842,16 @@ discard block |
||
842 | 842 | <?php //} ?> |
843 | 843 | |
844 | 844 | <?php |
845 | - if ( $show_pagination ) { |
|
846 | - $output_pagination = do_shortcode( '[facetwp pager="true"]' ); |
|
847 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
848 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
849 | - if ( isset( $this->facet_data[ $facet ] ) && in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
850 | - $output_pagination = do_shortcode( '[facetwp facet="pager_"]' ); |
|
845 | + if ($show_pagination) { |
|
846 | + $output_pagination = do_shortcode('[facetwp pager="true"]'); |
|
847 | + if (!empty($this->options['display'][$this->search_prefix.'_facets']) && is_array($this->options['display'][$this->search_prefix.'_facets'])) { |
|
848 | + foreach ($this->options['display'][$this->search_prefix.'_facets'] as $facet => $facet_useless) { |
|
849 | + if (isset($this->facet_data[$facet]) && in_array($this->facet_data[$facet]['type'], array('pager'))) { |
|
850 | + $output_pagination = do_shortcode('[facetwp facet="pager_"]'); |
|
851 | 851 | } |
852 | 852 | } |
853 | 853 | } |
854 | - echo wp_kses_post( $output_pagination ); |
|
854 | + echo wp_kses_post($output_pagination); |
|
855 | 855 | ?> |
856 | 856 | <?php } ?> |
857 | 857 | </div> |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | /** |
886 | 886 | * Disables default sidebar. |
887 | 887 | */ |
888 | - public function lsx_sidebar_enable( $sidebar_enabled ) { |
|
888 | + public function lsx_sidebar_enable($sidebar_enabled) { |
|
889 | 889 | $sidebar_enabled = false; |
890 | 890 | return $sidebar_enabled; |
891 | 891 | } |
@@ -895,19 +895,19 @@ discard block |
||
895 | 895 | */ |
896 | 896 | public function search_sidebar() { |
897 | 897 | |
898 | - $this->options = apply_filters( 'lsx_search_sidebar_options', $this->options ); |
|
898 | + $this->options = apply_filters('lsx_search_sidebar_options', $this->options); |
|
899 | 899 | ?> |
900 | - <?php do_action( 'lsx_search_sidebar_before' ); ?> |
|
900 | + <?php do_action('lsx_search_sidebar_before'); ?> |
|
901 | 901 | |
902 | - <div id="secondary" class="facetwp-sidebar widget-area <?php echo esc_attr( lsx_sidebar_class() ); ?>" role="complementary"> |
|
902 | + <div id="secondary" class="facetwp-sidebar widget-area <?php echo esc_attr(lsx_sidebar_class()); ?>" role="complementary"> |
|
903 | 903 | |
904 | - <?php do_action( 'lsx_search_sidebar_top' ); ?> |
|
904 | + <?php do_action('lsx_search_sidebar_top'); ?> |
|
905 | 905 | |
906 | - <?php if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { ?> |
|
906 | + <?php if (!empty($this->options['display'][$this->search_prefix.'_facets']) && is_array($this->options['display'][$this->search_prefix.'_facets'])) { ?> |
|
907 | 907 | <div class="row facetwp-row lsx-search-filer-area"> |
908 | - <h3 class="facetwp-filter-title"><?php echo esc_html_e( 'Refine by', 'lsx-search' ); ?></h3> |
|
908 | + <h3 class="facetwp-filter-title"><?php echo esc_html_e('Refine by', 'lsx-search'); ?></h3> |
|
909 | 909 | <div class="col-xs-12 facetwp-item facetwp-filters-button hidden-sm hidden-md hidden-lg"> |
910 | - <button class="ssm-toggle-nav btn btn-block" rel="lsx-search-filters"><?php esc_html_e( 'Filters', 'lsx-search' ); ?> <i class="fa fa-chevron-down" aria-hidden="true"></i></button> |
|
910 | + <button class="ssm-toggle-nav btn btn-block" rel="lsx-search-filters"><?php esc_html_e('Filters', 'lsx-search'); ?> <i class="fa fa-chevron-down" aria-hidden="true"></i></button> |
|
911 | 911 | </div> |
912 | 912 | |
913 | 913 | <div class="ssm-overlay ssm-toggle-nav" rel="lsx-search-filters"></div> |
@@ -915,16 +915,16 @@ discard block |
||
915 | 915 | <div class="col-xs-12 facetwp-item-wrap facetwp-filters-wrap" id="lsx-search-filters"> |
916 | 916 | <div class="row hidden-sm hidden-md hidden-lg ssm-row-margin-bottom"> |
917 | 917 | <div class="col-xs-12 facetwp-item facetwp-filters-button"> |
918 | - <button class="ssm-close-btn ssm-toggle-nav btn btn-block" rel="lsx-search-filters"><?php esc_html_e( 'Close Filters', 'lsx-search' ); ?> <i class="fa fa-times" aria-hidden="true"></i></button> |
|
918 | + <button class="ssm-close-btn ssm-toggle-nav btn btn-block" rel="lsx-search-filters"><?php esc_html_e('Close Filters', 'lsx-search'); ?> <i class="fa fa-times" aria-hidden="true"></i></button> |
|
919 | 919 | </div> |
920 | 920 | </div> |
921 | 921 | |
922 | 922 | <div class="row"> |
923 | 923 | <?php |
924 | 924 | // Slider. |
925 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
926 | - if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'alpha', 'search', 'pager' ) ) ) { |
|
927 | - $this->display_facet_default( $facet ); |
|
925 | + foreach ($this->options['display'][$this->search_prefix.'_facets'] as $facet => $facet_useless) { |
|
926 | + if (isset($this->facet_data[$facet]) && !in_array($this->facet_data[$facet]['type'], array('alpha', 'search', 'pager'))) { |
|
927 | + $this->display_facet_default($facet); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | ?> |
@@ -932,17 +932,17 @@ discard block |
||
932 | 932 | |
933 | 933 | <div class="row hidden-sm hidden-md hidden-lg ssm-row-margin-top"> |
934 | 934 | <div class="col-xs-12 facetwp-item facetwp-filters-button"> |
935 | - <button class="ssm-apply-btn ssm-toggle-nav btn btn-block" rel="lsx-search-filters"><?php esc_html_e( 'Apply Filters', 'lsx-search' ); ?> <i class="fa fa-check" aria-hidden="true"></i></button> |
|
935 | + <button class="ssm-apply-btn ssm-toggle-nav btn btn-block" rel="lsx-search-filters"><?php esc_html_e('Apply Filters', 'lsx-search'); ?> <i class="fa fa-check" aria-hidden="true"></i></button> |
|
936 | 936 | </div> |
937 | 937 | </div> |
938 | 938 | </div> |
939 | 939 | </div> |
940 | 940 | <?php } ?> |
941 | 941 | |
942 | - <?php do_action( 'lsx_search_sidebar_bottom' ); ?> |
|
942 | + <?php do_action('lsx_search_sidebar_bottom'); ?> |
|
943 | 943 | </div> |
944 | 944 | |
945 | - <?php do_action( 'lsx_search_sidebar_after' ); ?> |
|
945 | + <?php do_action('lsx_search_sidebar_after'); ?> |
|
946 | 946 | <?php |
947 | 947 | } |
948 | 948 | |
@@ -955,9 +955,9 @@ discard block |
||
955 | 955 | |
956 | 956 | $pager_facet_off = false; |
957 | 957 | |
958 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
959 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
960 | - if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
958 | + if (!empty($this->options['display'][$this->search_prefix.'_facets']) && is_array($this->options['display'][$this->search_prefix.'_facets'])) { |
|
959 | + foreach ($this->options['display'][$this->search_prefix.'_facets'] as $facet => $facet_useless) { |
|
960 | + if (isset($this->facet_data[$facet]) && !in_array($this->facet_data[$facet]['type'], array('pager'))) { |
|
961 | 961 | $pager_facet_off = true; |
962 | 962 | } |
963 | 963 | } |
@@ -971,9 +971,9 @@ discard block |
||
971 | 971 | */ |
972 | 972 | public function wc_archive_header() { |
973 | 973 | $default_size = 'sm'; |
974 | - $size = apply_filters( 'lsx_bootstrap_column_size', $default_size ); |
|
974 | + $size = apply_filters('lsx_bootstrap_column_size', $default_size); |
|
975 | 975 | ?> |
976 | - <div class="archive-header-wrapper banner-woocommerce col-<?php echo esc_attr( $size ); ?>-12"> |
|
976 | + <div class="archive-header-wrapper banner-woocommerce col-<?php echo esc_attr($size); ?>-12"> |
|
977 | 977 | <?php lsx_global_header_inner_bottom(); ?> |
978 | 978 | <header class="archive-header"> |
979 | 979 | <h1 class="archive-title"><?php woocommerce_page_title(); ?></h1> |
@@ -988,14 +988,14 @@ discard block |
||
988 | 988 | public function display_facet_search() { |
989 | 989 | ?> |
990 | 990 | <div class="col-xs-12 facetwp-item facetwp-form"> |
991 | - <form class="search-form lsx-search-form" action="<?php echo esc_attr( home_url() ); ?>" method="get"> |
|
991 | + <form class="search-form lsx-search-form" action="<?php echo esc_attr(home_url()); ?>" method="get"> |
|
992 | 992 | <div class="input-group"> |
993 | 993 | <div class="field"> |
994 | - <input class="facetwp-search search-field form-control" name="s" type="search" placeholder="<?php esc_html_e( 'Search', 'lsx-search' ); ?>..." autocomplete="off" value="<?php echo get_search_query() ?>"> |
|
994 | + <input class="facetwp-search search-field form-control" name="s" type="search" placeholder="<?php esc_html_e('Search', 'lsx-search'); ?>..." autocomplete="off" value="<?php echo get_search_query() ?>"> |
|
995 | 995 | </div> |
996 | 996 | |
997 | 997 | <div class="field submit-button"> |
998 | - <button class="search-submit btn" type="submit"><?php esc_html_e( 'Search', 'lsx-search' ); ?></button> |
|
998 | + <button class="search-submit btn" type="submit"><?php esc_html_e('Search', 'lsx-search'); ?></button> |
|
999 | 999 | </div> |
1000 | 1000 | </div> |
1001 | 1001 | </form> |
@@ -1006,26 +1006,26 @@ discard block |
||
1006 | 1006 | /** |
1007 | 1007 | * Display facet default. |
1008 | 1008 | */ |
1009 | - public function display_facet_default( $facet ) { |
|
1009 | + public function display_facet_default($facet) { |
|
1010 | 1010 | |
1011 | - $show_collapse = ! isset( $this->options['display'][$this->search_prefix . '_collapse'] ) || 'on' !== $this->options['display'][$this->search_prefix . '_collapse']; |
|
1011 | + $show_collapse = !isset($this->options['display'][$this->search_prefix.'_collapse']) || 'on' !== $this->options['display'][$this->search_prefix.'_collapse']; |
|
1012 | 1012 | $col_class = ''; |
1013 | 1013 | |
1014 | - if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?> |
|
1015 | - <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
|
1014 | + if ('search' === $this->facet_data[$facet]['type']) : ?> |
|
1015 | + <?php echo do_shortcode('[facetwp facet="'.$facet.'"]'); ?> |
|
1016 | 1016 | <?php else : ?> |
1017 | - <div class="col-xs-12 facetwp-item parent-facetwp-facet-<?php echo esc_html( $facet ); ?> <?php echo esc_attr( $col_class ); ?>"> |
|
1018 | - <?php if ( ! $show_collapse ) { ?> |
|
1017 | + <div class="col-xs-12 facetwp-item parent-facetwp-facet-<?php echo esc_html($facet); ?> <?php echo esc_attr($col_class); ?>"> |
|
1018 | + <?php if (!$show_collapse) { ?> |
|
1019 | 1019 | <div class="facetwp-collapsed"> |
1020 | - <h3 class="lsx-search-title"><?php echo wp_kses_post( $this->facet_data[ $facet ]['label'] ); ?></h3> |
|
1021 | - <button title="<?php echo esc_html_e( 'Click to Expand', 'lsx-search' ); ?>" class="facetwp-collapse" type="button" data-toggle="collapse" data-target="#collapse-<?php echo esc_html( $facet ); ?>" aria-expanded="false" aria-controls="collapse-<?php echo esc_html( $facet ); ?>"></button> |
|
1020 | + <h3 class="lsx-search-title"><?php echo wp_kses_post($this->facet_data[$facet]['label']); ?></h3> |
|
1021 | + <button title="<?php echo esc_html_e('Click to Expand', 'lsx-search'); ?>" class="facetwp-collapse" type="button" data-toggle="collapse" data-target="#collapse-<?php echo esc_html($facet); ?>" aria-expanded="false" aria-controls="collapse-<?php echo esc_html($facet); ?>"></button> |
|
1022 | 1022 | </div> |
1023 | - <div id="collapse-<?php echo esc_html( $facet ); ?>" class="collapse"> |
|
1024 | - <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
|
1023 | + <div id="collapse-<?php echo esc_html($facet); ?>" class="collapse"> |
|
1024 | + <?php echo do_shortcode('[facetwp facet="'.$facet.'"]'); ?> |
|
1025 | 1025 | </div> |
1026 | 1026 | <?php } else { ?> |
1027 | - <h3 class="lsx-search-title"><?php echo wp_kses_post( $this->facet_data[ $facet ]['label'] ); ?></h3> |
|
1028 | - <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
|
1027 | + <h3 class="lsx-search-title"><?php echo wp_kses_post($this->facet_data[$facet]['label']); ?></h3> |
|
1028 | + <?php echo do_shortcode('[facetwp facet="'.$facet.'"]'); ?> |
|
1029 | 1029 | <?php } ?> |
1030 | 1030 | </div> |
1031 | 1031 | <?php |
@@ -1035,8 +1035,8 @@ discard block |
||
1035 | 1035 | /** |
1036 | 1036 | * Changes slot column class. |
1037 | 1037 | */ |
1038 | - public function change_slot_column_class( $class ) { |
|
1039 | - if ( is_post_type_archive( 'video' ) || is_tax( 'video-category' ) ) { |
|
1038 | + public function change_slot_column_class($class) { |
|
1039 | + if (is_post_type_archive('video') || is_tax('video-category')) { |
|
1040 | 1040 | $column_class = 'col-xs-12 col-sm-4'; |
1041 | 1041 | } |
1042 | 1042 | |
@@ -1047,15 +1047,15 @@ discard block |
||
1047 | 1047 | * Add post type label to the title. |
1048 | 1048 | */ |
1049 | 1049 | public function add_label_to_title() { |
1050 | - if ( is_search() ) { |
|
1051 | - if ( ! empty( $this->options['display']['engine_search_enable_pt_label'] ) ) { |
|
1050 | + if (is_search()) { |
|
1051 | + if (!empty($this->options['display']['engine_search_enable_pt_label'])) { |
|
1052 | 1052 | $post_type = get_post_type(); |
1053 | - $post_type = str_replace( '_', ' ', $post_type ); |
|
1054 | - $post_type = str_replace( '-', ' ', $post_type ); |
|
1055 | - if ( 'tribe events' === $post_type ) { |
|
1053 | + $post_type = str_replace('_', ' ', $post_type); |
|
1054 | + $post_type = str_replace('-', ' ', $post_type); |
|
1055 | + if ('tribe events' === $post_type) { |
|
1056 | 1056 | $post_type = 'Events'; |
1057 | 1057 | } |
1058 | - echo wp_kses_post( ' <span class="label label-default lsx-label-post-type">' . $post_type . '</span>' ); |
|
1058 | + echo wp_kses_post(' <span class="label label-default lsx-label-post-type">'.$post_type.'</span>'); |
|
1059 | 1059 | } |
1060 | 1060 | } |
1061 | 1061 | } |
@@ -1063,22 +1063,22 @@ discard block |
||
1063 | 1063 | /** |
1064 | 1064 | * Changes the sort options. |
1065 | 1065 | */ |
1066 | - public function facetwp_sort_options( $options, $params ) { |
|
1066 | + public function facetwp_sort_options($options, $params) { |
|
1067 | 1067 | $this->set_vars(); |
1068 | 1068 | |
1069 | - if ( true === $this->search_enabled ) { |
|
1070 | - if ( 'default' !== $params['template_name'] && 'wp' !== $params['template_name'] ) { |
|
1069 | + if (true === $this->search_enabled) { |
|
1070 | + if ('default' !== $params['template_name'] && 'wp' !== $params['template_name']) { |
|
1071 | 1071 | return $options; |
1072 | 1072 | } |
1073 | 1073 | |
1074 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_date' ] ) ) { |
|
1075 | - unset( $options['date_desc'] ); |
|
1076 | - unset( $options['date_asc'] ); |
|
1074 | + if (!empty($this->options['display'][$this->search_prefix.'_disable_date'])) { |
|
1075 | + unset($options['date_desc']); |
|
1076 | + unset($options['date_asc']); |
|
1077 | 1077 | } |
1078 | 1078 | |
1079 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_az_sorting' ] ) ) { |
|
1080 | - unset( $options['title_desc'] ); |
|
1081 | - unset( $options['title_asc'] ); |
|
1079 | + if (!empty($this->options['display'][$this->search_prefix.'_disable_az_sorting'])) { |
|
1080 | + unset($options['title_desc']); |
|
1081 | + unset($options['title_asc']); |
|
1082 | 1082 | } |
1083 | 1083 | } |
1084 | 1084 | |
@@ -1091,9 +1091,9 @@ discard block |
||
1091 | 1091 | * |
1092 | 1092 | * @return mixed |
1093 | 1093 | */ |
1094 | - public function kses_allowed_html( $allowedtags, $context ) { |
|
1094 | + public function kses_allowed_html($allowedtags, $context) { |
|
1095 | 1095 | $allowedtags['a']['data-value'] = true; |
1096 | - $allowedtags['a']['data-selection'] = true; |
|
1096 | + $allowedtags['a']['data-selection'] = true; |
|
1097 | 1097 | $allowedtags['button']['data-toggle'] = true; |
1098 | 1098 | return $allowedtags; |
1099 | 1099 | } |
@@ -1101,29 +1101,29 @@ discard block |
||
1101 | 1101 | /** |
1102 | 1102 | * Change FaceWP result count HTML |
1103 | 1103 | */ |
1104 | - public function get_search_query( $keyword ) { |
|
1105 | - global $wp_rewrite,$wp_query; |
|
1104 | + public function get_search_query($keyword) { |
|
1105 | + global $wp_rewrite, $wp_query; |
|
1106 | 1106 | |
1107 | - if ( empty( $keyword ) ) { |
|
1108 | - if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
1107 | + if (empty($keyword)) { |
|
1108 | + if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { |
|
1109 | 1109 | return; |
1110 | 1110 | } |
1111 | 1111 | $search_base = $wp_rewrite->search_base; |
1112 | - if ( strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) !== false ) { |
|
1113 | - $words = explode( "/{$search_base}/", $_SERVER['REQUEST_URI'] ); |
|
1114 | - $limit = count( $words ); |
|
1115 | - if ( isset( $words[ $limit - 1 ] ) ) { |
|
1116 | - $keyword = $words[ $limit - 1 ]; |
|
1112 | + if (strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") !== false) { |
|
1113 | + $words = explode("/{$search_base}/", $_SERVER['REQUEST_URI']); |
|
1114 | + $limit = count($words); |
|
1115 | + if (isset($words[$limit - 1])) { |
|
1116 | + $keyword = $words[$limit - 1]; |
|
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - $needle = trim( '/ ' ); |
|
1122 | - $words = explode( $needle, $keyword ); |
|
1123 | - if ( is_array( $words ) && ! empty( $words ) ) { |
|
1124 | - $keyword = $words[ count( $words ) - 1 ]; |
|
1121 | + $needle = trim('/ '); |
|
1122 | + $words = explode($needle, $keyword); |
|
1123 | + if (is_array($words) && !empty($words)) { |
|
1124 | + $keyword = $words[count($words) - 1]; |
|
1125 | 1125 | } |
1126 | - $keyword = str_replace( '+', ' ', $keyword ); |
|
1126 | + $keyword = str_replace('+', ' ', $keyword); |
|
1127 | 1127 | return $keyword; |
1128 | 1128 | } |
1129 | 1129 | } |