@@ -9,663 +9,663 @@ 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_action( 'pre_get_posts', array( $this, 'filter_post_types' ) ); |
|
80 | - |
|
81 | - add_filter( 'lsx_search_post_types', array( $this, 'register_post_types' ) ); |
|
82 | - add_filter( 'lsx_search_taxonomies', array( $this, 'register_taxonomies' ) ); |
|
83 | - add_filter( 'lsx_search_post_types_plural', array( $this, 'register_post_type_tabs' ) ); |
|
84 | - add_filter( 'facetwp_sort_options', array( $this, 'facetwp_sort_options' ), 10, 2 ); |
|
85 | - add_filter( 'wp_kses_allowed_html', array( $this, 'kses_allowed_html' ), 20, 2 ); |
|
86 | - |
|
87 | - // Redirects. |
|
88 | - add_action( 'template_redirect', array( $this, 'pretty_search_redirect' ) ); |
|
89 | - add_filter( 'pre_get_posts', array( $this, 'pretty_search_parse_query' ) ); |
|
90 | - |
|
91 | - add_action( 'lsx_search_sidebar_top', array( $this, 'search_sidebar_top' ) ); |
|
92 | - add_filter( 'facetwp_facet_html', array( $this, 'search_facet_html' ), 10, 2 ); |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Return an instance of this class. |
|
97 | - * |
|
98 | - * @since 1.0.0 |
|
99 | - * |
|
100 | - * @return object \lsx\member_directory\search\Frontend() A single instance of this class. |
|
101 | - */ |
|
102 | - public static function get_instance() { |
|
103 | - // If the single instance hasn't been set, set it now. |
|
104 | - if ( null === self::$instance ) { |
|
105 | - self::$instance = new self(); |
|
106 | - } |
|
107 | - return self::$instance; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Loads the variable classes and the static classes. |
|
112 | - */ |
|
113 | - private function load_classes() { |
|
114 | - require_once LSX_SEARCH_PATH . 'classes/frontend/class-layout.php'; |
|
115 | - $this->layout = frontend\Layout::get_instance(); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Check all settings. |
|
120 | - */ |
|
121 | - public function set_vars() { |
|
122 | - $post_type = ''; |
|
123 | - |
|
124 | - $this->post_types = apply_filters( 'lsx_search_post_types', array() ); |
|
125 | - $this->taxonomies = apply_filters( 'lsx_search_taxonomies', array() ); |
|
126 | - $this->tabs = apply_filters( 'lsx_search_post_types_plural', array() ); |
|
127 | - $this->options = apply_filters( 'lsx_search_options', $this->options ); |
|
128 | - $this->post_types = get_post_types(); |
|
129 | - $this->post_type_slugs = array( |
|
130 | - 'post' => 'posts', |
|
131 | - 'project' => 'projects', |
|
132 | - 'service' => 'services', |
|
133 | - 'team' => 'team', |
|
134 | - 'testimonial' => 'testimonials', |
|
135 | - 'video' => 'videos', |
|
136 | - 'product' => 'products', |
|
137 | - ); |
|
138 | - $this->set_search_prefix(); |
|
139 | - $this->get_cmb2_options(); |
|
140 | - $this->search_enabled = apply_filters( 'lsx_search_enabled', $this->is_search_enabled(), $this ); |
|
141 | - $this->search_prefix = apply_filters( 'lsx_search_prefix', $this->search_prefix, $this ); |
|
142 | - } |
|
143 | - |
|
144 | - private function get_cmb2_options() { |
|
145 | - $cmb2_options = get_option( 'lsx-search-settings' ); |
|
146 | - if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
147 | - $this->set_search_prefix( true ); |
|
148 | - $this->options['display'] = $cmb2_options; |
|
149 | - foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
150 | - if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
151 | - $new_values = array(); |
|
152 | - foreach ( $option_value as $empty_key => $key_value ) { |
|
153 | - $new_values[ $key_value ] = 'on'; |
|
154 | - } |
|
155 | - $this->options['display'][ $option_key ] = $new_values; |
|
156 | - } |
|
157 | - } |
|
158 | - $this->new_options = true; |
|
159 | - $this->disable_to_search_actions(); |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - private function disable_to_search_actions() { |
|
164 | - global $lsx_to_search_fwp, $lsx_to_search; |
|
165 | - if ( null !== $lsx_to_search ) { |
|
166 | - // Redirects. |
|
167 | - remove_filter( 'template_include', array( $lsx_to_search, 'search_template_include' ), 99 ); |
|
168 | - remove_action( 'template_redirect', array( $lsx_to_search, 'pretty_search_redirect' ) ); |
|
169 | - remove_filter( 'pre_get_posts', array( $lsx_to_search, 'pretty_search_parse_query' ) ); |
|
170 | - |
|
171 | - // Layout Filter. |
|
172 | - remove_filter( 'lsx_layout', array( $lsx_to_search, 'lsx_layout' ), 20, 1 ); |
|
173 | - remove_filter( 'lsx_layout_selector', array( $lsx_to_search, 'lsx_layout_selector' ), 10, 4 ); |
|
174 | - remove_filter( 'lsx_to_archive_layout', array( $lsx_to_search, 'lsx_to_search_archive_layout' ), 10, 2 ); |
|
175 | - |
|
176 | - remove_action( 'lsx_search_sidebar_top', array( $lsx_to_search, 'search_sidebar_top' ) ); |
|
177 | - remove_action( 'pre_get_posts', array( $lsx_to_search, 'price_sorting' ), 100 ); |
|
178 | - |
|
179 | - //add_shortcode( 'lsx_search_form', array( 'LSX_TO_Search_Frontend', 'search_form' ) ); |
|
180 | - remove_filter( 'searchwp_short_circuit', array( $lsx_to_search, 'searchwp_short_circuit' ), 10, 2 ); |
|
181 | - remove_filter( 'get_search_query', array( $lsx_to_search, 'get_search_query' ) ); |
|
182 | - remove_filter( 'body_class', array( $lsx_to_search, 'to_add_search_url_class' ), 20 ); |
|
183 | - |
|
184 | - remove_filter( 'facetwp_preload_url_vars', array( $lsx_to_search, 'preload_url_vars' ), 10, 1 ); |
|
185 | - remove_filter( 'wpseo_json_ld_search_url', array( $lsx_to_search, 'change_json_ld_search_url' ), 10, 1 ); |
|
186 | - } |
|
187 | - if ( null !== $lsx_to_search_fwp ) { |
|
188 | - remove_filter( 'facetwp_indexer_row_data', array( $lsx_to_search_fwp, 'facetwp_index_row_data' ), 10, 2 ); |
|
189 | - remove_filter( 'facetwp_index_row', array( $lsx_to_search_fwp, 'facetwp_index_row' ), 10, 2 ); |
|
190 | - |
|
191 | - remove_filter( 'facetwp_sort_options', array( $lsx_to_search_fwp, 'facet_sort_options' ), 10, 2 ); |
|
192 | - |
|
193 | - remove_filter( 'facetwp_pager_html', array( $lsx_to_search_fwp, 'facetwp_pager_html' ), 10, 2 ); |
|
194 | - remove_filter( 'facetwp_result_count', array( $lsx_to_search_fwp, 'facetwp_result_count' ), 10, 2 ); |
|
195 | - |
|
196 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'destination_facet_html' ), 10, 2 ); |
|
197 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'slide_facet_html' ), 10, 2 ); |
|
198 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'search_facet_html' ), 10, 2 ); |
|
199 | - remove_filter( 'facetwp_load_css', array( $lsx_to_search_fwp, 'facetwp_load_css' ), 10, 1 ); |
|
200 | - |
|
201 | - if ( class_exists( 'LSX_Currencies' ) ) { |
|
202 | - remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_lsx_currencies' ), 10, 2 ); |
|
203 | - } else { |
|
204 | - remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_to_currencies' ), 10, 2 ); |
|
205 | - } |
|
206 | - } |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Returns if the search is enabled. |
|
211 | - * |
|
212 | - * @return boolean |
|
213 | - */ |
|
214 | - public function is_search_enabled() { |
|
215 | - $search_enabled = false; |
|
216 | - |
|
217 | - if ( false === $this->new_options ) { |
|
218 | - 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 | - $search_enabled = true; |
|
220 | - } |
|
221 | - } else { |
|
222 | - $enable_prefix = $this->search_prefix; |
|
223 | - if ( ! empty( $this->options ) && isset( $this->options['display'] ) && isset( $this->options['display'][ $enable_prefix . '_enable' ] ) && 'on' === $this->options['display'][ $enable_prefix . '_enable' ] ) { |
|
224 | - $search_enabled = true; |
|
225 | - } |
|
226 | - } |
|
227 | - return $search_enabled; |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Sets the search prefix. |
|
232 | - * |
|
233 | - * @return void |
|
234 | - */ |
|
235 | - private function set_search_prefix( $new_prefixes = false ) { |
|
236 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
237 | - if ( false !== $new_prefixes ) { |
|
238 | - $this->taxonomies = array(); |
|
239 | - $this->post_types = array(); |
|
240 | - } |
|
241 | - |
|
242 | - if ( is_search() ) { |
|
243 | - if ( false === $new_prefixes ) { |
|
244 | - $this->search_core_suffix = 'core'; |
|
245 | - $this->search_prefix = 'search'; |
|
246 | - } else { |
|
247 | - $this->search_core_suffix = 'enable'; |
|
248 | - $this->search_prefix = 'engine_search'; |
|
249 | - } |
|
250 | - } elseif ( is_post_type_archive( $this->post_types ) || is_tax() || is_page( $page_for_posts ) || is_home() || is_category() || is_tag() ) { |
|
251 | - if ( false === $new_prefixes ) { |
|
252 | - $this->search_core_suffix = 'search'; |
|
253 | - } else { |
|
254 | - $this->search_core_suffix = 'enable'; |
|
255 | - } |
|
256 | - |
|
257 | - if ( is_tax() ) { |
|
258 | - $tax = get_query_var( 'taxonomy' ); |
|
259 | - $tax = get_taxonomy( $tax ); |
|
260 | - $post_type = $tax->object_type[0]; |
|
261 | - } else if ( is_page( $page_for_posts ) || is_category() || is_tag() || is_home() ) { |
|
262 | - $post_type = 'post'; |
|
263 | - } else { |
|
264 | - $post_type = get_query_var( 'post_type' ); |
|
265 | - } |
|
266 | - |
|
267 | - if ( false === $new_prefixes ) { |
|
268 | - if ( isset( $this->tabs[ $post_type ] ) ) { |
|
269 | - $this->search_prefix = $this->tabs[ $post_type ] . '_archive'; |
|
270 | - } |
|
271 | - } else { |
|
272 | - $this->search_prefix = $post_type . '_search'; |
|
273 | - } |
|
274 | - } |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Sets the FacetWP variables. |
|
279 | - */ |
|
280 | - public function set_facetwp_vars() { |
|
281 | - |
|
282 | - if ( class_exists( 'FacetWP' ) ) { |
|
283 | - $facet_data = FWP()->helper->get_facets(); |
|
284 | - } |
|
285 | - |
|
286 | - $this->facet_data = array(); |
|
287 | - |
|
288 | - $this->facet_data['search_form'] = array( |
|
289 | - 'name' => 'search_form', |
|
290 | - 'label' => esc_html__( 'Search Form', 'lsx-search' ), |
|
291 | - ); |
|
292 | - |
|
293 | - if ( ! empty( $facet_data ) && is_array( $facet_data ) ) { |
|
294 | - foreach ( $facet_data as $facet ) { |
|
295 | - $this->facet_data[ $facet['name'] ] = $facet; |
|
296 | - } |
|
297 | - } |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * Check all settings. |
|
302 | - */ |
|
303 | - public function core() { |
|
304 | - |
|
305 | - if ( true === $this->search_enabled ) { |
|
306 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 999 ); |
|
307 | - |
|
308 | - add_filter( 'lsx_layout', array( $this, 'lsx_layout' ), 20, 1 ); |
|
309 | - add_filter( 'lsx_layout_selector', array( $this, 'lsx_layout_selector' ), 10, 4 ); |
|
310 | - add_filter( 'lsx_slot_class', array( $this, 'change_slot_column_class' ) ); |
|
311 | - add_action( 'lsx_entry_top', array( $this, 'add_label_to_title' ) ); |
|
312 | - add_filter( 'body_class', array( $this, 'body_class' ), 10 ); |
|
313 | - |
|
314 | - add_filter( 'lsx_blog_customizer_top_of_blog_action', array( $this, 'top_of_blog_action' ), 10, 1 ); |
|
315 | - add_filter( 'lsx_blog_customizer_blog_description_class', array( $this, 'blog_description_class' ), 10, 1 ); |
|
316 | - |
|
317 | - if ( class_exists( 'LSX_Videos' ) ) { |
|
318 | - global $lsx_videos_frontend; |
|
319 | - remove_action( 'lsx_content_top', array( $lsx_videos_frontend, 'categories_tabs' ), 15 ); |
|
320 | - } |
|
321 | - |
|
322 | - add_filter( 'lsx_paging_nav_disable', '__return_true' ); |
|
323 | - add_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
324 | - add_action( 'lsx_content_top', array( $this, 'facetwp_tempate_open' ) ); |
|
325 | - add_action( 'lsx_content_bottom', array( $this, 'facetwp_tempate_close' ) ); |
|
326 | - add_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
327 | - |
|
328 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) && '1c' !== $this->options['display'][ $this->search_prefix . '_layout' ] ) { |
|
329 | - add_filter( 'lsx_sidebar_enable', array( $this, 'lsx_sidebar_enable' ), 10, 1 ); |
|
330 | - } |
|
331 | - |
|
332 | - add_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
333 | - |
|
334 | - if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) { |
|
335 | - remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' ); |
|
336 | - remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' ); |
|
337 | - add_filter( 'woocommerce_show_page_title', '__return_false' ); |
|
338 | - |
|
339 | - add_filter( 'loop_shop_columns', function() { |
|
340 | - return 3; |
|
341 | - } ); |
|
342 | - |
|
343 | - // Actions added by LSX theme |
|
344 | - remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
|
345 | - add_action( 'lsx_content_wrap_before', array( $this, 'wc_archive_header' ), 140 ); |
|
346 | - |
|
347 | - // Actions added be LSX theme / woocommerce.php file |
|
348 | - remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
349 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
350 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 ); |
|
351 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 ); |
|
352 | - remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
353 | - |
|
354 | - // Actions added be LSX theme / woocommerce.php file |
|
355 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
356 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
357 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
358 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 ); |
|
359 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
360 | - } |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - /** |
|
365 | - * Adds a search class to the body to allow the styling of the sidebars etc. |
|
366 | - * |
|
367 | - * @param array $classes The classes. |
|
368 | - * @return array $classes The classes. |
|
369 | - */ |
|
370 | - public function body_class( $classes ) { |
|
371 | - $classes[] = 'lsx-search-enabled'; |
|
372 | - return $classes; |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Moves the blog description to above the content columns. |
|
377 | - * |
|
378 | - * @param string $action |
|
379 | - * @return string $action |
|
380 | - */ |
|
381 | - public function top_of_blog_action( $action = '' ) { |
|
382 | - $action = 'lsx_content_wrap_before'; |
|
383 | - return $action; |
|
384 | - } |
|
385 | - |
|
386 | - /** |
|
387 | - * Adds a class to the blog description. |
|
388 | - * |
|
389 | - * @param string $action |
|
390 | - * @return string $action |
|
391 | - */ |
|
392 | - public function blog_description_class( $class = '' ) { |
|
393 | - $class .= ' col-md-12 search-description'; |
|
394 | - return $class; |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Check the $wp_query global to see if there are posts in the current query. |
|
399 | - * |
|
400 | - * @return void |
|
401 | - */ |
|
402 | - public function check_for_results() { |
|
403 | - if ( true === $this->search_enabled ) { |
|
404 | - global $wp_query; |
|
405 | - if ( empty( $wp_query->posts ) ) { |
|
406 | - $this->has_posts = false; |
|
407 | - remove_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
408 | - remove_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
409 | - remove_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
410 | - } else { |
|
411 | - $this->has_posts = true; |
|
412 | - } |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - /** |
|
417 | - * Filter the post types. |
|
418 | - */ |
|
419 | - public function filter_post_types( $query ) { |
|
420 | - if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { |
|
421 | - if ( ! empty( $this->options ) && ! empty( $this->options['display']['search_enable_core'] ) ) { |
|
422 | - if ( ! empty( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
423 | - $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
424 | - $query->set( 'post_type', $post_types ); |
|
425 | - } |
|
426 | - } |
|
427 | - } |
|
428 | - } |
|
429 | - |
|
430 | - /** |
|
431 | - * Sets post types with active search options. |
|
432 | - */ |
|
433 | - public function register_post_types( $post_types ) { |
|
434 | - $post_types = array( 'post', 'project', 'service', 'team', 'testimonial', 'video', 'product' ); |
|
435 | - return $post_types; |
|
436 | - } |
|
437 | - |
|
438 | - /** |
|
439 | - * Sets taxonomies with active search options. |
|
440 | - */ |
|
441 | - public function register_taxonomies( $taxonomies ) { |
|
442 | - $taxonomies = array( 'category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag' ); |
|
443 | - return $taxonomies; |
|
444 | - } |
|
445 | - |
|
446 | - /** |
|
447 | - * Sets post types with active search options. |
|
448 | - */ |
|
449 | - public function register_post_type_tabs( $post_types_plural ) { |
|
450 | - $post_types_plural = array( |
|
451 | - 'post' => 'posts', |
|
452 | - 'project' => 'projects', |
|
453 | - 'service' => 'services', |
|
454 | - 'team' => 'team', |
|
455 | - 'testimonial' => 'testimonials', |
|
456 | - 'video' => 'videos', |
|
457 | - 'product' => 'products', // WooCommerce |
|
458 | - ); |
|
459 | - return $post_types_plural; |
|
460 | - } |
|
461 | - |
|
462 | - /** |
|
463 | - * Enqueue styles and scripts. |
|
464 | - */ |
|
465 | - public function assets() { |
|
466 | - add_filter( 'lsx_defer_parsing_of_js', array( $this, 'skip_js_defer' ), 10, 4 ); |
|
467 | - wp_enqueue_script( 'touchSwipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.touchSwipe.min.js', array( 'jquery' ), LSX_SEARCH_VER, true ); |
|
468 | - wp_enqueue_script( 'slideandswipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.slideandswipe.min.js', array( 'jquery', 'touchSwipe' ), LSX_SEARCH_VER, true ); |
|
469 | - 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 ); |
|
470 | - |
|
471 | - $params = apply_filters( 'lsx_search_js_params', array( |
|
472 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
473 | - )); |
|
474 | - |
|
475 | - wp_localize_script( 'lsx-search', 'lsx_customizer_params', $params ); |
|
476 | - |
|
477 | - wp_enqueue_style( 'lsx-search', LSX_SEARCH_URL . 'assets/css/lsx-search.css', array(), LSX_SEARCH_VER ); |
|
478 | - wp_style_add_data( 'lsx-search', 'rtl', 'replace' ); |
|
479 | - |
|
480 | - if ( true === $this->new_options ) { |
|
481 | - wp_deregister_style( 'lsx_to_search' ); |
|
482 | - wp_deregister_script( 'lsx_to_search' ); |
|
483 | - } |
|
484 | - } |
|
485 | - |
|
486 | - /** |
|
487 | - * Adds the to-search.min.js and the to-search.js |
|
488 | - * |
|
489 | - * @param boolean $should_skip |
|
490 | - * @param string $tag |
|
491 | - * @param string $handle |
|
492 | - * @param string $href |
|
493 | - * @return boolean |
|
494 | - */ |
|
495 | - public function skip_js_defer( $should_skip, $tag, $handle, $href ) { |
|
496 | - if ( ! is_admin() && ( false !== stripos( $href, 'lsx-search.min.js' ) || false !== stripos( $href, 'lsx-search.js' ) ) ) { |
|
497 | - $should_skip = true; |
|
498 | - } |
|
499 | - return $should_skip; |
|
500 | - } |
|
501 | - |
|
502 | - /** |
|
503 | - * Redirect wordpress to the search template located in the plugin |
|
504 | - * |
|
505 | - * @param $template |
|
506 | - * @return $template |
|
507 | - */ |
|
508 | - public function search_template_include( $template ) { |
|
509 | - if ( is_main_query() && is_search() ) { |
|
510 | - if ( file_exists( LSX_SEARCH_PATH . 'templates/search.php' ) ) { |
|
511 | - $template = LSX_SEARCH_PATH . 'templates/search.php'; |
|
512 | - } |
|
513 | - } |
|
514 | - |
|
515 | - return $template; |
|
516 | - } |
|
517 | - |
|
518 | - /** |
|
519 | - * Rewrite the search URL |
|
520 | - */ |
|
521 | - public function pretty_search_redirect() { |
|
522 | - global $wp_rewrite,$wp_query; |
|
523 | - |
|
524 | - if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
525 | - return; |
|
526 | - } |
|
527 | - |
|
528 | - $search_base = $wp_rewrite->search_base; |
|
529 | - |
|
530 | - if ( is_search() && ! is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { |
|
531 | - $search_query = get_query_var( 's' ); |
|
532 | - $engine = ''; |
|
533 | - |
|
534 | - // If the search was triggered by a supplemental engine. |
|
535 | - if ( isset( $_GET['engine'] ) && 'default' !== $_GET['engine'] ) { |
|
536 | - $engine = $_GET['engine']; |
|
537 | - set_query_var( 'engine', $engine ); |
|
538 | - $engine = array_search( $engine, $this->post_type_slugs, true ) . '/'; |
|
539 | - } |
|
540 | - |
|
541 | - $get_array = $_GET; |
|
542 | - |
|
543 | - if ( is_array( $get_array ) && ! empty( $get_array ) ) { |
|
544 | - $vars_to_maintain = array(); |
|
545 | - |
|
546 | - foreach ( $get_array as $ga_key => $ga_value ) { |
|
547 | - if ( false !== strpos( $ga_key, 'fwp_' ) ) { |
|
548 | - $vars_to_maintain[] = $ga_key . '=' . $ga_value; |
|
549 | - } |
|
550 | - } |
|
551 | - } |
|
552 | - |
|
553 | - $redirect_url = home_url( "/{$search_base}/" . $engine . urlencode( $search_query ) ); |
|
554 | - |
|
555 | - if ( ! empty( $vars_to_maintain ) ) { |
|
556 | - $redirect_url .= '?' . implode( '&', $vars_to_maintain ); |
|
557 | - } |
|
558 | - |
|
559 | - wp_redirect( $redirect_url ); |
|
560 | - exit(); |
|
561 | - } |
|
562 | - } |
|
563 | - |
|
564 | - /** |
|
565 | - * Parse the Query and trigger a search |
|
566 | - */ |
|
567 | - public function pretty_search_parse_query( $query ) { |
|
568 | - $this->post_type_slugs = array( |
|
569 | - 'post' => 'posts', |
|
570 | - 'project' => 'projects', |
|
571 | - 'service' => 'services', |
|
572 | - 'team' => 'team', |
|
573 | - 'testimonial' => 'testimonials', |
|
574 | - 'video' => 'videos', |
|
575 | - 'product' => 'products', // WooCommerce |
|
576 | - ); |
|
577 | - if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) { |
|
578 | - $search_query = $query->get( 's' ); |
|
579 | - $keyword_test = explode( '/', $search_query ); |
|
580 | - |
|
581 | - $index = array_search( $keyword_test[0], $this->post_type_slugs, true ); |
|
582 | - if ( false !== $index ) { |
|
583 | - $engine = $this->post_type_slugs[ $index ]; |
|
584 | - |
|
585 | - $query->set( 'post_type', $engine ); |
|
586 | - $query->set( 'engine', $engine ); |
|
587 | - |
|
588 | - if ( count( $keyword_test ) > 1 ) { |
|
589 | - $query->set( 's', $keyword_test[1] ); |
|
590 | - } elseif ( post_type_exists( $engine ) ) { |
|
591 | - $query->set( 's', '' ); |
|
592 | - } |
|
593 | - } else { |
|
594 | - if ( isset( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
595 | - $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
596 | - $query->set( 'post_type', $post_types ); |
|
597 | - } |
|
598 | - } |
|
599 | - } |
|
600 | - |
|
601 | - return $query; |
|
602 | - } |
|
603 | - |
|
604 | - /** |
|
605 | - * Change the search slug to /search/ for the JSON+LD output in Yoast SEO |
|
606 | - * |
|
607 | - * @return url |
|
608 | - */ |
|
609 | - public function change_json_ld_search_url() { |
|
610 | - return trailingslashit( home_url() ) . 'search/{search_term_string}'; |
|
611 | - } |
|
612 | - |
|
613 | - /** |
|
614 | - * A filter to set the layout to 2 column. |
|
615 | - */ |
|
616 | - public function lsx_layout( $layout ) { |
|
617 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
618 | - if ( false === $this->has_posts ) { |
|
619 | - $layout = '1c'; |
|
620 | - } else { |
|
621 | - $layout = $this->options['display'][ $this->search_prefix . '_layout' ]; |
|
622 | - } |
|
623 | - } |
|
624 | - return $layout; |
|
625 | - } |
|
626 | - |
|
627 | - /** |
|
628 | - * Outputs the Search Title Facet |
|
629 | - */ |
|
630 | - public function search_sidebar_top() { |
|
631 | - 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 ) ) { |
|
632 | - |
|
633 | - if ( ! is_search() ) { |
|
634 | - |
|
635 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
636 | - |
|
637 | - if ( isset( $this->facet_data[ $facet ] ) && 'search' === $this->facet_data[ $facet ]['type'] ) { |
|
638 | - echo wp_kses_post( '<div class="row">' ); |
|
639 | - $this->display_facet_default( $facet ); |
|
640 | - echo wp_kses_post( '</div>' ); |
|
641 | - unset( $this->options['display'][ $this->search_prefix . '_facets' ][ $facet ] ); |
|
642 | - } |
|
643 | - } |
|
644 | - } else { |
|
645 | - echo wp_kses_post( '<div class="row">' ); |
|
646 | - $this->display_facet_search(); |
|
647 | - echo wp_kses_post( '</div>' ); |
|
648 | - } |
|
649 | - } |
|
650 | - } |
|
651 | - |
|
652 | - /** |
|
653 | - * Overrides the search facet HTML |
|
654 | - * @param $output |
|
655 | - * @param $params |
|
656 | - * |
|
657 | - * @return string |
|
658 | - */ |
|
659 | - public function search_facet_html( $output, $params ) { |
|
660 | - if ( 'search' == $params['facet']['type'] ) { |
|
661 | - |
|
662 | - $value = (array) $params['selected_values']; |
|
663 | - $value = empty( $value ) ? '' : stripslashes( $value[0] ); |
|
664 | - $placeholder = isset( $params['facet']['placeholder'] ) ? $params['facet']['placeholder'] : __( 'Search...', 'lsx-search' ); |
|
665 | - $placeholder = facetwp_i18n( $placeholder ); |
|
666 | - |
|
667 | - ob_start(); |
|
668 | - ?> |
|
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_action( 'pre_get_posts', array( $this, 'filter_post_types' ) ); |
|
80 | + |
|
81 | + add_filter( 'lsx_search_post_types', array( $this, 'register_post_types' ) ); |
|
82 | + add_filter( 'lsx_search_taxonomies', array( $this, 'register_taxonomies' ) ); |
|
83 | + add_filter( 'lsx_search_post_types_plural', array( $this, 'register_post_type_tabs' ) ); |
|
84 | + add_filter( 'facetwp_sort_options', array( $this, 'facetwp_sort_options' ), 10, 2 ); |
|
85 | + add_filter( 'wp_kses_allowed_html', array( $this, 'kses_allowed_html' ), 20, 2 ); |
|
86 | + |
|
87 | + // Redirects. |
|
88 | + add_action( 'template_redirect', array( $this, 'pretty_search_redirect' ) ); |
|
89 | + add_filter( 'pre_get_posts', array( $this, 'pretty_search_parse_query' ) ); |
|
90 | + |
|
91 | + add_action( 'lsx_search_sidebar_top', array( $this, 'search_sidebar_top' ) ); |
|
92 | + add_filter( 'facetwp_facet_html', array( $this, 'search_facet_html' ), 10, 2 ); |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Return an instance of this class. |
|
97 | + * |
|
98 | + * @since 1.0.0 |
|
99 | + * |
|
100 | + * @return object \lsx\member_directory\search\Frontend() A single instance of this class. |
|
101 | + */ |
|
102 | + public static function get_instance() { |
|
103 | + // If the single instance hasn't been set, set it now. |
|
104 | + if ( null === self::$instance ) { |
|
105 | + self::$instance = new self(); |
|
106 | + } |
|
107 | + return self::$instance; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Loads the variable classes and the static classes. |
|
112 | + */ |
|
113 | + private function load_classes() { |
|
114 | + require_once LSX_SEARCH_PATH . 'classes/frontend/class-layout.php'; |
|
115 | + $this->layout = frontend\Layout::get_instance(); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Check all settings. |
|
120 | + */ |
|
121 | + public function set_vars() { |
|
122 | + $post_type = ''; |
|
123 | + |
|
124 | + $this->post_types = apply_filters( 'lsx_search_post_types', array() ); |
|
125 | + $this->taxonomies = apply_filters( 'lsx_search_taxonomies', array() ); |
|
126 | + $this->tabs = apply_filters( 'lsx_search_post_types_plural', array() ); |
|
127 | + $this->options = apply_filters( 'lsx_search_options', $this->options ); |
|
128 | + $this->post_types = get_post_types(); |
|
129 | + $this->post_type_slugs = array( |
|
130 | + 'post' => 'posts', |
|
131 | + 'project' => 'projects', |
|
132 | + 'service' => 'services', |
|
133 | + 'team' => 'team', |
|
134 | + 'testimonial' => 'testimonials', |
|
135 | + 'video' => 'videos', |
|
136 | + 'product' => 'products', |
|
137 | + ); |
|
138 | + $this->set_search_prefix(); |
|
139 | + $this->get_cmb2_options(); |
|
140 | + $this->search_enabled = apply_filters( 'lsx_search_enabled', $this->is_search_enabled(), $this ); |
|
141 | + $this->search_prefix = apply_filters( 'lsx_search_prefix', $this->search_prefix, $this ); |
|
142 | + } |
|
143 | + |
|
144 | + private function get_cmb2_options() { |
|
145 | + $cmb2_options = get_option( 'lsx-search-settings' ); |
|
146 | + if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
147 | + $this->set_search_prefix( true ); |
|
148 | + $this->options['display'] = $cmb2_options; |
|
149 | + foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
150 | + if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
151 | + $new_values = array(); |
|
152 | + foreach ( $option_value as $empty_key => $key_value ) { |
|
153 | + $new_values[ $key_value ] = 'on'; |
|
154 | + } |
|
155 | + $this->options['display'][ $option_key ] = $new_values; |
|
156 | + } |
|
157 | + } |
|
158 | + $this->new_options = true; |
|
159 | + $this->disable_to_search_actions(); |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + private function disable_to_search_actions() { |
|
164 | + global $lsx_to_search_fwp, $lsx_to_search; |
|
165 | + if ( null !== $lsx_to_search ) { |
|
166 | + // Redirects. |
|
167 | + remove_filter( 'template_include', array( $lsx_to_search, 'search_template_include' ), 99 ); |
|
168 | + remove_action( 'template_redirect', array( $lsx_to_search, 'pretty_search_redirect' ) ); |
|
169 | + remove_filter( 'pre_get_posts', array( $lsx_to_search, 'pretty_search_parse_query' ) ); |
|
170 | + |
|
171 | + // Layout Filter. |
|
172 | + remove_filter( 'lsx_layout', array( $lsx_to_search, 'lsx_layout' ), 20, 1 ); |
|
173 | + remove_filter( 'lsx_layout_selector', array( $lsx_to_search, 'lsx_layout_selector' ), 10, 4 ); |
|
174 | + remove_filter( 'lsx_to_archive_layout', array( $lsx_to_search, 'lsx_to_search_archive_layout' ), 10, 2 ); |
|
175 | + |
|
176 | + remove_action( 'lsx_search_sidebar_top', array( $lsx_to_search, 'search_sidebar_top' ) ); |
|
177 | + remove_action( 'pre_get_posts', array( $lsx_to_search, 'price_sorting' ), 100 ); |
|
178 | + |
|
179 | + //add_shortcode( 'lsx_search_form', array( 'LSX_TO_Search_Frontend', 'search_form' ) ); |
|
180 | + remove_filter( 'searchwp_short_circuit', array( $lsx_to_search, 'searchwp_short_circuit' ), 10, 2 ); |
|
181 | + remove_filter( 'get_search_query', array( $lsx_to_search, 'get_search_query' ) ); |
|
182 | + remove_filter( 'body_class', array( $lsx_to_search, 'to_add_search_url_class' ), 20 ); |
|
183 | + |
|
184 | + remove_filter( 'facetwp_preload_url_vars', array( $lsx_to_search, 'preload_url_vars' ), 10, 1 ); |
|
185 | + remove_filter( 'wpseo_json_ld_search_url', array( $lsx_to_search, 'change_json_ld_search_url' ), 10, 1 ); |
|
186 | + } |
|
187 | + if ( null !== $lsx_to_search_fwp ) { |
|
188 | + remove_filter( 'facetwp_indexer_row_data', array( $lsx_to_search_fwp, 'facetwp_index_row_data' ), 10, 2 ); |
|
189 | + remove_filter( 'facetwp_index_row', array( $lsx_to_search_fwp, 'facetwp_index_row' ), 10, 2 ); |
|
190 | + |
|
191 | + remove_filter( 'facetwp_sort_options', array( $lsx_to_search_fwp, 'facet_sort_options' ), 10, 2 ); |
|
192 | + |
|
193 | + remove_filter( 'facetwp_pager_html', array( $lsx_to_search_fwp, 'facetwp_pager_html' ), 10, 2 ); |
|
194 | + remove_filter( 'facetwp_result_count', array( $lsx_to_search_fwp, 'facetwp_result_count' ), 10, 2 ); |
|
195 | + |
|
196 | + remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'destination_facet_html' ), 10, 2 ); |
|
197 | + remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'slide_facet_html' ), 10, 2 ); |
|
198 | + remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'search_facet_html' ), 10, 2 ); |
|
199 | + remove_filter( 'facetwp_load_css', array( $lsx_to_search_fwp, 'facetwp_load_css' ), 10, 1 ); |
|
200 | + |
|
201 | + if ( class_exists( 'LSX_Currencies' ) ) { |
|
202 | + remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_lsx_currencies' ), 10, 2 ); |
|
203 | + } else { |
|
204 | + remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_to_currencies' ), 10, 2 ); |
|
205 | + } |
|
206 | + } |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Returns if the search is enabled. |
|
211 | + * |
|
212 | + * @return boolean |
|
213 | + */ |
|
214 | + public function is_search_enabled() { |
|
215 | + $search_enabled = false; |
|
216 | + |
|
217 | + if ( false === $this->new_options ) { |
|
218 | + 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 | + $search_enabled = true; |
|
220 | + } |
|
221 | + } else { |
|
222 | + $enable_prefix = $this->search_prefix; |
|
223 | + if ( ! empty( $this->options ) && isset( $this->options['display'] ) && isset( $this->options['display'][ $enable_prefix . '_enable' ] ) && 'on' === $this->options['display'][ $enable_prefix . '_enable' ] ) { |
|
224 | + $search_enabled = true; |
|
225 | + } |
|
226 | + } |
|
227 | + return $search_enabled; |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Sets the search prefix. |
|
232 | + * |
|
233 | + * @return void |
|
234 | + */ |
|
235 | + private function set_search_prefix( $new_prefixes = false ) { |
|
236 | + $page_for_posts = get_option( 'page_for_posts' ); |
|
237 | + if ( false !== $new_prefixes ) { |
|
238 | + $this->taxonomies = array(); |
|
239 | + $this->post_types = array(); |
|
240 | + } |
|
241 | + |
|
242 | + if ( is_search() ) { |
|
243 | + if ( false === $new_prefixes ) { |
|
244 | + $this->search_core_suffix = 'core'; |
|
245 | + $this->search_prefix = 'search'; |
|
246 | + } else { |
|
247 | + $this->search_core_suffix = 'enable'; |
|
248 | + $this->search_prefix = 'engine_search'; |
|
249 | + } |
|
250 | + } elseif ( is_post_type_archive( $this->post_types ) || is_tax() || is_page( $page_for_posts ) || is_home() || is_category() || is_tag() ) { |
|
251 | + if ( false === $new_prefixes ) { |
|
252 | + $this->search_core_suffix = 'search'; |
|
253 | + } else { |
|
254 | + $this->search_core_suffix = 'enable'; |
|
255 | + } |
|
256 | + |
|
257 | + if ( is_tax() ) { |
|
258 | + $tax = get_query_var( 'taxonomy' ); |
|
259 | + $tax = get_taxonomy( $tax ); |
|
260 | + $post_type = $tax->object_type[0]; |
|
261 | + } else if ( is_page( $page_for_posts ) || is_category() || is_tag() || is_home() ) { |
|
262 | + $post_type = 'post'; |
|
263 | + } else { |
|
264 | + $post_type = get_query_var( 'post_type' ); |
|
265 | + } |
|
266 | + |
|
267 | + if ( false === $new_prefixes ) { |
|
268 | + if ( isset( $this->tabs[ $post_type ] ) ) { |
|
269 | + $this->search_prefix = $this->tabs[ $post_type ] . '_archive'; |
|
270 | + } |
|
271 | + } else { |
|
272 | + $this->search_prefix = $post_type . '_search'; |
|
273 | + } |
|
274 | + } |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Sets the FacetWP variables. |
|
279 | + */ |
|
280 | + public function set_facetwp_vars() { |
|
281 | + |
|
282 | + if ( class_exists( 'FacetWP' ) ) { |
|
283 | + $facet_data = FWP()->helper->get_facets(); |
|
284 | + } |
|
285 | + |
|
286 | + $this->facet_data = array(); |
|
287 | + |
|
288 | + $this->facet_data['search_form'] = array( |
|
289 | + 'name' => 'search_form', |
|
290 | + 'label' => esc_html__( 'Search Form', 'lsx-search' ), |
|
291 | + ); |
|
292 | + |
|
293 | + if ( ! empty( $facet_data ) && is_array( $facet_data ) ) { |
|
294 | + foreach ( $facet_data as $facet ) { |
|
295 | + $this->facet_data[ $facet['name'] ] = $facet; |
|
296 | + } |
|
297 | + } |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * Check all settings. |
|
302 | + */ |
|
303 | + public function core() { |
|
304 | + |
|
305 | + if ( true === $this->search_enabled ) { |
|
306 | + add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 999 ); |
|
307 | + |
|
308 | + add_filter( 'lsx_layout', array( $this, 'lsx_layout' ), 20, 1 ); |
|
309 | + add_filter( 'lsx_layout_selector', array( $this, 'lsx_layout_selector' ), 10, 4 ); |
|
310 | + add_filter( 'lsx_slot_class', array( $this, 'change_slot_column_class' ) ); |
|
311 | + add_action( 'lsx_entry_top', array( $this, 'add_label_to_title' ) ); |
|
312 | + add_filter( 'body_class', array( $this, 'body_class' ), 10 ); |
|
313 | + |
|
314 | + add_filter( 'lsx_blog_customizer_top_of_blog_action', array( $this, 'top_of_blog_action' ), 10, 1 ); |
|
315 | + add_filter( 'lsx_blog_customizer_blog_description_class', array( $this, 'blog_description_class' ), 10, 1 ); |
|
316 | + |
|
317 | + if ( class_exists( 'LSX_Videos' ) ) { |
|
318 | + global $lsx_videos_frontend; |
|
319 | + remove_action( 'lsx_content_top', array( $lsx_videos_frontend, 'categories_tabs' ), 15 ); |
|
320 | + } |
|
321 | + |
|
322 | + add_filter( 'lsx_paging_nav_disable', '__return_true' ); |
|
323 | + add_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
324 | + add_action( 'lsx_content_top', array( $this, 'facetwp_tempate_open' ) ); |
|
325 | + add_action( 'lsx_content_bottom', array( $this, 'facetwp_tempate_close' ) ); |
|
326 | + add_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
327 | + |
|
328 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) && '1c' !== $this->options['display'][ $this->search_prefix . '_layout' ] ) { |
|
329 | + add_filter( 'lsx_sidebar_enable', array( $this, 'lsx_sidebar_enable' ), 10, 1 ); |
|
330 | + } |
|
331 | + |
|
332 | + add_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
333 | + |
|
334 | + if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) { |
|
335 | + remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' ); |
|
336 | + remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' ); |
|
337 | + add_filter( 'woocommerce_show_page_title', '__return_false' ); |
|
338 | + |
|
339 | + add_filter( 'loop_shop_columns', function() { |
|
340 | + return 3; |
|
341 | + } ); |
|
342 | + |
|
343 | + // Actions added by LSX theme |
|
344 | + remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
|
345 | + add_action( 'lsx_content_wrap_before', array( $this, 'wc_archive_header' ), 140 ); |
|
346 | + |
|
347 | + // Actions added be LSX theme / woocommerce.php file |
|
348 | + remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
349 | + remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
350 | + remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 ); |
|
351 | + remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 ); |
|
352 | + remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
353 | + |
|
354 | + // Actions added be LSX theme / woocommerce.php file |
|
355 | + remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
356 | + remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
357 | + remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
358 | + remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 ); |
|
359 | + remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
360 | + } |
|
361 | + } |
|
362 | + } |
|
363 | + |
|
364 | + /** |
|
365 | + * Adds a search class to the body to allow the styling of the sidebars etc. |
|
366 | + * |
|
367 | + * @param array $classes The classes. |
|
368 | + * @return array $classes The classes. |
|
369 | + */ |
|
370 | + public function body_class( $classes ) { |
|
371 | + $classes[] = 'lsx-search-enabled'; |
|
372 | + return $classes; |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * Moves the blog description to above the content columns. |
|
377 | + * |
|
378 | + * @param string $action |
|
379 | + * @return string $action |
|
380 | + */ |
|
381 | + public function top_of_blog_action( $action = '' ) { |
|
382 | + $action = 'lsx_content_wrap_before'; |
|
383 | + return $action; |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * Adds a class to the blog description. |
|
388 | + * |
|
389 | + * @param string $action |
|
390 | + * @return string $action |
|
391 | + */ |
|
392 | + public function blog_description_class( $class = '' ) { |
|
393 | + $class .= ' col-md-12 search-description'; |
|
394 | + return $class; |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * Check the $wp_query global to see if there are posts in the current query. |
|
399 | + * |
|
400 | + * @return void |
|
401 | + */ |
|
402 | + public function check_for_results() { |
|
403 | + if ( true === $this->search_enabled ) { |
|
404 | + global $wp_query; |
|
405 | + if ( empty( $wp_query->posts ) ) { |
|
406 | + $this->has_posts = false; |
|
407 | + remove_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
408 | + remove_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
409 | + remove_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
410 | + } else { |
|
411 | + $this->has_posts = true; |
|
412 | + } |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + /** |
|
417 | + * Filter the post types. |
|
418 | + */ |
|
419 | + public function filter_post_types( $query ) { |
|
420 | + if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { |
|
421 | + if ( ! empty( $this->options ) && ! empty( $this->options['display']['search_enable_core'] ) ) { |
|
422 | + if ( ! empty( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
423 | + $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
424 | + $query->set( 'post_type', $post_types ); |
|
425 | + } |
|
426 | + } |
|
427 | + } |
|
428 | + } |
|
429 | + |
|
430 | + /** |
|
431 | + * Sets post types with active search options. |
|
432 | + */ |
|
433 | + public function register_post_types( $post_types ) { |
|
434 | + $post_types = array( 'post', 'project', 'service', 'team', 'testimonial', 'video', 'product' ); |
|
435 | + return $post_types; |
|
436 | + } |
|
437 | + |
|
438 | + /** |
|
439 | + * Sets taxonomies with active search options. |
|
440 | + */ |
|
441 | + public function register_taxonomies( $taxonomies ) { |
|
442 | + $taxonomies = array( 'category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag' ); |
|
443 | + return $taxonomies; |
|
444 | + } |
|
445 | + |
|
446 | + /** |
|
447 | + * Sets post types with active search options. |
|
448 | + */ |
|
449 | + public function register_post_type_tabs( $post_types_plural ) { |
|
450 | + $post_types_plural = array( |
|
451 | + 'post' => 'posts', |
|
452 | + 'project' => 'projects', |
|
453 | + 'service' => 'services', |
|
454 | + 'team' => 'team', |
|
455 | + 'testimonial' => 'testimonials', |
|
456 | + 'video' => 'videos', |
|
457 | + 'product' => 'products', // WooCommerce |
|
458 | + ); |
|
459 | + return $post_types_plural; |
|
460 | + } |
|
461 | + |
|
462 | + /** |
|
463 | + * Enqueue styles and scripts. |
|
464 | + */ |
|
465 | + public function assets() { |
|
466 | + add_filter( 'lsx_defer_parsing_of_js', array( $this, 'skip_js_defer' ), 10, 4 ); |
|
467 | + wp_enqueue_script( 'touchSwipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.touchSwipe.min.js', array( 'jquery' ), LSX_SEARCH_VER, true ); |
|
468 | + wp_enqueue_script( 'slideandswipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.slideandswipe.min.js', array( 'jquery', 'touchSwipe' ), LSX_SEARCH_VER, true ); |
|
469 | + 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 ); |
|
470 | + |
|
471 | + $params = apply_filters( 'lsx_search_js_params', array( |
|
472 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
473 | + )); |
|
474 | + |
|
475 | + wp_localize_script( 'lsx-search', 'lsx_customizer_params', $params ); |
|
476 | + |
|
477 | + wp_enqueue_style( 'lsx-search', LSX_SEARCH_URL . 'assets/css/lsx-search.css', array(), LSX_SEARCH_VER ); |
|
478 | + wp_style_add_data( 'lsx-search', 'rtl', 'replace' ); |
|
479 | + |
|
480 | + if ( true === $this->new_options ) { |
|
481 | + wp_deregister_style( 'lsx_to_search' ); |
|
482 | + wp_deregister_script( 'lsx_to_search' ); |
|
483 | + } |
|
484 | + } |
|
485 | + |
|
486 | + /** |
|
487 | + * Adds the to-search.min.js and the to-search.js |
|
488 | + * |
|
489 | + * @param boolean $should_skip |
|
490 | + * @param string $tag |
|
491 | + * @param string $handle |
|
492 | + * @param string $href |
|
493 | + * @return boolean |
|
494 | + */ |
|
495 | + public function skip_js_defer( $should_skip, $tag, $handle, $href ) { |
|
496 | + if ( ! is_admin() && ( false !== stripos( $href, 'lsx-search.min.js' ) || false !== stripos( $href, 'lsx-search.js' ) ) ) { |
|
497 | + $should_skip = true; |
|
498 | + } |
|
499 | + return $should_skip; |
|
500 | + } |
|
501 | + |
|
502 | + /** |
|
503 | + * Redirect wordpress to the search template located in the plugin |
|
504 | + * |
|
505 | + * @param $template |
|
506 | + * @return $template |
|
507 | + */ |
|
508 | + public function search_template_include( $template ) { |
|
509 | + if ( is_main_query() && is_search() ) { |
|
510 | + if ( file_exists( LSX_SEARCH_PATH . 'templates/search.php' ) ) { |
|
511 | + $template = LSX_SEARCH_PATH . 'templates/search.php'; |
|
512 | + } |
|
513 | + } |
|
514 | + |
|
515 | + return $template; |
|
516 | + } |
|
517 | + |
|
518 | + /** |
|
519 | + * Rewrite the search URL |
|
520 | + */ |
|
521 | + public function pretty_search_redirect() { |
|
522 | + global $wp_rewrite,$wp_query; |
|
523 | + |
|
524 | + if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
525 | + return; |
|
526 | + } |
|
527 | + |
|
528 | + $search_base = $wp_rewrite->search_base; |
|
529 | + |
|
530 | + if ( is_search() && ! is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { |
|
531 | + $search_query = get_query_var( 's' ); |
|
532 | + $engine = ''; |
|
533 | + |
|
534 | + // If the search was triggered by a supplemental engine. |
|
535 | + if ( isset( $_GET['engine'] ) && 'default' !== $_GET['engine'] ) { |
|
536 | + $engine = $_GET['engine']; |
|
537 | + set_query_var( 'engine', $engine ); |
|
538 | + $engine = array_search( $engine, $this->post_type_slugs, true ) . '/'; |
|
539 | + } |
|
540 | + |
|
541 | + $get_array = $_GET; |
|
542 | + |
|
543 | + if ( is_array( $get_array ) && ! empty( $get_array ) ) { |
|
544 | + $vars_to_maintain = array(); |
|
545 | + |
|
546 | + foreach ( $get_array as $ga_key => $ga_value ) { |
|
547 | + if ( false !== strpos( $ga_key, 'fwp_' ) ) { |
|
548 | + $vars_to_maintain[] = $ga_key . '=' . $ga_value; |
|
549 | + } |
|
550 | + } |
|
551 | + } |
|
552 | + |
|
553 | + $redirect_url = home_url( "/{$search_base}/" . $engine . urlencode( $search_query ) ); |
|
554 | + |
|
555 | + if ( ! empty( $vars_to_maintain ) ) { |
|
556 | + $redirect_url .= '?' . implode( '&', $vars_to_maintain ); |
|
557 | + } |
|
558 | + |
|
559 | + wp_redirect( $redirect_url ); |
|
560 | + exit(); |
|
561 | + } |
|
562 | + } |
|
563 | + |
|
564 | + /** |
|
565 | + * Parse the Query and trigger a search |
|
566 | + */ |
|
567 | + public function pretty_search_parse_query( $query ) { |
|
568 | + $this->post_type_slugs = array( |
|
569 | + 'post' => 'posts', |
|
570 | + 'project' => 'projects', |
|
571 | + 'service' => 'services', |
|
572 | + 'team' => 'team', |
|
573 | + 'testimonial' => 'testimonials', |
|
574 | + 'video' => 'videos', |
|
575 | + 'product' => 'products', // WooCommerce |
|
576 | + ); |
|
577 | + if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) { |
|
578 | + $search_query = $query->get( 's' ); |
|
579 | + $keyword_test = explode( '/', $search_query ); |
|
580 | + |
|
581 | + $index = array_search( $keyword_test[0], $this->post_type_slugs, true ); |
|
582 | + if ( false !== $index ) { |
|
583 | + $engine = $this->post_type_slugs[ $index ]; |
|
584 | + |
|
585 | + $query->set( 'post_type', $engine ); |
|
586 | + $query->set( 'engine', $engine ); |
|
587 | + |
|
588 | + if ( count( $keyword_test ) > 1 ) { |
|
589 | + $query->set( 's', $keyword_test[1] ); |
|
590 | + } elseif ( post_type_exists( $engine ) ) { |
|
591 | + $query->set( 's', '' ); |
|
592 | + } |
|
593 | + } else { |
|
594 | + if ( isset( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
595 | + $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
596 | + $query->set( 'post_type', $post_types ); |
|
597 | + } |
|
598 | + } |
|
599 | + } |
|
600 | + |
|
601 | + return $query; |
|
602 | + } |
|
603 | + |
|
604 | + /** |
|
605 | + * Change the search slug to /search/ for the JSON+LD output in Yoast SEO |
|
606 | + * |
|
607 | + * @return url |
|
608 | + */ |
|
609 | + public function change_json_ld_search_url() { |
|
610 | + return trailingslashit( home_url() ) . 'search/{search_term_string}'; |
|
611 | + } |
|
612 | + |
|
613 | + /** |
|
614 | + * A filter to set the layout to 2 column. |
|
615 | + */ |
|
616 | + public function lsx_layout( $layout ) { |
|
617 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
618 | + if ( false === $this->has_posts ) { |
|
619 | + $layout = '1c'; |
|
620 | + } else { |
|
621 | + $layout = $this->options['display'][ $this->search_prefix . '_layout' ]; |
|
622 | + } |
|
623 | + } |
|
624 | + return $layout; |
|
625 | + } |
|
626 | + |
|
627 | + /** |
|
628 | + * Outputs the Search Title Facet |
|
629 | + */ |
|
630 | + public function search_sidebar_top() { |
|
631 | + 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 ) ) { |
|
632 | + |
|
633 | + if ( ! is_search() ) { |
|
634 | + |
|
635 | + foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
636 | + |
|
637 | + if ( isset( $this->facet_data[ $facet ] ) && 'search' === $this->facet_data[ $facet ]['type'] ) { |
|
638 | + echo wp_kses_post( '<div class="row">' ); |
|
639 | + $this->display_facet_default( $facet ); |
|
640 | + echo wp_kses_post( '</div>' ); |
|
641 | + unset( $this->options['display'][ $this->search_prefix . '_facets' ][ $facet ] ); |
|
642 | + } |
|
643 | + } |
|
644 | + } else { |
|
645 | + echo wp_kses_post( '<div class="row">' ); |
|
646 | + $this->display_facet_search(); |
|
647 | + echo wp_kses_post( '</div>' ); |
|
648 | + } |
|
649 | + } |
|
650 | + } |
|
651 | + |
|
652 | + /** |
|
653 | + * Overrides the search facet HTML |
|
654 | + * @param $output |
|
655 | + * @param $params |
|
656 | + * |
|
657 | + * @return string |
|
658 | + */ |
|
659 | + public function search_facet_html( $output, $params ) { |
|
660 | + if ( 'search' == $params['facet']['type'] ) { |
|
661 | + |
|
662 | + $value = (array) $params['selected_values']; |
|
663 | + $value = empty( $value ) ? '' : stripslashes( $value[0] ); |
|
664 | + $placeholder = isset( $params['facet']['placeholder'] ) ? $params['facet']['placeholder'] : __( 'Search...', 'lsx-search' ); |
|
665 | + $placeholder = facetwp_i18n( $placeholder ); |
|
666 | + |
|
667 | + ob_start(); |
|
668 | + ?> |
|
669 | 669 | <div class="col-xs-12 facetwp-item facetwp-form"> |
670 | 670 | <div class="search-form lsx-search-form 2"> |
671 | 671 | <div class="input-group facetwp-search-wrap"> |
@@ -680,74 +680,74 @@ discard block |
||
680 | 680 | </div> |
681 | 681 | </div> |
682 | 682 | <?php |
683 | - $output = ob_get_clean(); |
|
684 | - } |
|
685 | - return $output; |
|
686 | - } |
|
687 | - |
|
688 | - /** |
|
689 | - * Change the primary and secondary column classes. |
|
690 | - */ |
|
691 | - public function lsx_layout_selector( $return_class, $class, $layout, $size ) { |
|
692 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
693 | - |
|
694 | - if ( '2cl' === $layout || '2cr' === $layout ) { |
|
695 | - $main_class = 'col-sm-8 col-md-9'; |
|
696 | - $sidebar_class = 'col-sm-4 col-md-3'; |
|
697 | - |
|
698 | - if ( '2cl' === $layout ) { |
|
699 | - $main_class .= ' col-sm-pull-4 col-md-pull-3'; |
|
700 | - $sidebar_class .= ' col-sm-push-8 col-md-push-9'; |
|
701 | - } |
|
702 | - |
|
703 | - if ( 'main' === $class ) { |
|
704 | - return $main_class; |
|
705 | - } |
|
706 | - |
|
707 | - if ( 'sidebar' === $class ) { |
|
708 | - return $sidebar_class; |
|
709 | - } |
|
710 | - } |
|
711 | - } |
|
712 | - |
|
713 | - return $return_class; |
|
714 | - } |
|
715 | - |
|
716 | - /** |
|
717 | - * Displays the Alphabet sorter above the facets. |
|
718 | - * |
|
719 | - * @return void |
|
720 | - */ |
|
721 | - public function display_alphabet_facet() { |
|
722 | - if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
723 | - $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
724 | - } else { |
|
725 | - $az_pagination = false; |
|
726 | - } |
|
727 | - $az_pagination = apply_filters( 'lsx_search_top_az_pagination', $az_pagination ); |
|
728 | - if ( false !== $az_pagination && '' !== $az_pagination ) { |
|
729 | - echo do_shortcode( '[facetwp facet="' . $az_pagination . '"]' ); |
|
730 | - } |
|
731 | - } |
|
732 | - |
|
733 | - /** |
|
734 | - * Outputs top. |
|
735 | - */ |
|
736 | - public function facet_top_bar() { |
|
737 | - if ( true === apply_filters( 'lsx_search_hide_top_bar', false ) ) { |
|
738 | - return; |
|
739 | - } |
|
740 | - $show_pagination = true; |
|
741 | - $pagination_visible = false; |
|
742 | - $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
743 | - $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_all_sorting' ] ); |
|
744 | - |
|
745 | - $show_pagination = apply_filters( 'lsx_search_top_show_pagination', $show_pagination ); |
|
746 | - $pagination_visible = apply_filters( 'lsx_search_top_pagination_visible', $pagination_visible ); |
|
747 | - $show_per_page_combo = apply_filters( 'lsx_search_top_show_per_page_combo', $show_per_page_combo ); |
|
748 | - $show_sort_combo = apply_filters( 'lsx_search_top_show_sort_combo', $show_sort_combo ); |
|
749 | - $facet_row_classes = apply_filters( 'lsx_search_top_facetwp_row_classes', '' ); |
|
750 | - ?> |
|
683 | + $output = ob_get_clean(); |
|
684 | + } |
|
685 | + return $output; |
|
686 | + } |
|
687 | + |
|
688 | + /** |
|
689 | + * Change the primary and secondary column classes. |
|
690 | + */ |
|
691 | + public function lsx_layout_selector( $return_class, $class, $layout, $size ) { |
|
692 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
693 | + |
|
694 | + if ( '2cl' === $layout || '2cr' === $layout ) { |
|
695 | + $main_class = 'col-sm-8 col-md-9'; |
|
696 | + $sidebar_class = 'col-sm-4 col-md-3'; |
|
697 | + |
|
698 | + if ( '2cl' === $layout ) { |
|
699 | + $main_class .= ' col-sm-pull-4 col-md-pull-3'; |
|
700 | + $sidebar_class .= ' col-sm-push-8 col-md-push-9'; |
|
701 | + } |
|
702 | + |
|
703 | + if ( 'main' === $class ) { |
|
704 | + return $main_class; |
|
705 | + } |
|
706 | + |
|
707 | + if ( 'sidebar' === $class ) { |
|
708 | + return $sidebar_class; |
|
709 | + } |
|
710 | + } |
|
711 | + } |
|
712 | + |
|
713 | + return $return_class; |
|
714 | + } |
|
715 | + |
|
716 | + /** |
|
717 | + * Displays the Alphabet sorter above the facets. |
|
718 | + * |
|
719 | + * @return void |
|
720 | + */ |
|
721 | + public function display_alphabet_facet() { |
|
722 | + if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
723 | + $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
724 | + } else { |
|
725 | + $az_pagination = false; |
|
726 | + } |
|
727 | + $az_pagination = apply_filters( 'lsx_search_top_az_pagination', $az_pagination ); |
|
728 | + if ( false !== $az_pagination && '' !== $az_pagination ) { |
|
729 | + echo do_shortcode( '[facetwp facet="' . $az_pagination . '"]' ); |
|
730 | + } |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * Outputs top. |
|
735 | + */ |
|
736 | + public function facet_top_bar() { |
|
737 | + if ( true === apply_filters( 'lsx_search_hide_top_bar', false ) ) { |
|
738 | + return; |
|
739 | + } |
|
740 | + $show_pagination = true; |
|
741 | + $pagination_visible = false; |
|
742 | + $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
743 | + $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_all_sorting' ] ); |
|
744 | + |
|
745 | + $show_pagination = apply_filters( 'lsx_search_top_show_pagination', $show_pagination ); |
|
746 | + $pagination_visible = apply_filters( 'lsx_search_top_pagination_visible', $pagination_visible ); |
|
747 | + $show_per_page_combo = apply_filters( 'lsx_search_top_show_per_page_combo', $show_per_page_combo ); |
|
748 | + $show_sort_combo = apply_filters( 'lsx_search_top_show_sort_combo', $show_sort_combo ); |
|
749 | + $facet_row_classes = apply_filters( 'lsx_search_top_facetwp_row_classes', '' ); |
|
750 | + ?> |
|
751 | 751 | <div id="facetwp-top"> |
752 | 752 | <?php if ( $show_sort_combo || ( $show_pagination && $show_per_page_combo ) ) { ?> |
753 | 753 | <div class="row facetwp-top-row-1 hidden-xs <?php echo esc_attr( $facet_row_classes ); ?>"> |
@@ -778,32 +778,32 @@ discard block |
||
778 | 778 | <?php } ?> |
779 | 779 | </div> |
780 | 780 | <?php |
781 | - } |
|
782 | - |
|
783 | - /** |
|
784 | - * Outputs bottom. |
|
785 | - */ |
|
786 | - public function facet_bottom_bar() { |
|
787 | - if ( true === apply_filters( 'lsx_search_hide_bottom_bar', false ) ) { |
|
788 | - return; |
|
789 | - } |
|
790 | - $show_pagination = true; |
|
791 | - $pagination_visible = false; |
|
792 | - if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
793 | - $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
794 | - } else { |
|
795 | - $az_pagination = false; |
|
796 | - } |
|
797 | - |
|
798 | - $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
799 | - $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_all_sorting' ] ); |
|
800 | - |
|
801 | - $show_pagination = apply_filters( 'lsx_search_bottom_show_pagination', $show_pagination ); |
|
802 | - $pagination_visible = apply_filters( 'lsx_search_bottom_pagination_visible', $pagination_visible ); |
|
803 | - $show_per_page_combo = apply_filters( 'lsx_search_bottom_show_per_page_combo', $show_per_page_combo ); |
|
804 | - $show_sort_combo = apply_filters( 'lsx_search_bottom_show_sort_combo', $show_sort_combo ); |
|
805 | - |
|
806 | - if ( $show_pagination || ! empty( $az_pagination ) ) { ?> |
|
781 | + } |
|
782 | + |
|
783 | + /** |
|
784 | + * Outputs bottom. |
|
785 | + */ |
|
786 | + public function facet_bottom_bar() { |
|
787 | + if ( true === apply_filters( 'lsx_search_hide_bottom_bar', false ) ) { |
|
788 | + return; |
|
789 | + } |
|
790 | + $show_pagination = true; |
|
791 | + $pagination_visible = false; |
|
792 | + if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
793 | + $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
794 | + } else { |
|
795 | + $az_pagination = false; |
|
796 | + } |
|
797 | + |
|
798 | + $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
799 | + $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_all_sorting' ] ); |
|
800 | + |
|
801 | + $show_pagination = apply_filters( 'lsx_search_bottom_show_pagination', $show_pagination ); |
|
802 | + $pagination_visible = apply_filters( 'lsx_search_bottom_pagination_visible', $pagination_visible ); |
|
803 | + $show_per_page_combo = apply_filters( 'lsx_search_bottom_show_per_page_combo', $show_per_page_combo ); |
|
804 | + $show_sort_combo = apply_filters( 'lsx_search_bottom_show_sort_combo', $show_sort_combo ); |
|
805 | + |
|
806 | + if ( $show_pagination || ! empty( $az_pagination ) ) { ?> |
|
807 | 807 | <div id="facetwp-bottom"> |
808 | 808 | <div class="row facetwp-bottom-row-1"> |
809 | 809 | <div class="col-xs-12"> |
@@ -818,61 +818,61 @@ discard block |
||
818 | 818 | <?php //} ?> |
819 | 819 | |
820 | 820 | <?php |
821 | - if ( $show_pagination ) { |
|
822 | - $output_pagination = do_shortcode( '[facetwp pager="true"]' ); |
|
823 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
824 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
825 | - if ( isset( $this->facet_data[ $facet ] ) && in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
826 | - $output_pagination = do_shortcode( '[facetwp facet="pager_"]' ); |
|
827 | - } |
|
828 | - } |
|
829 | - } |
|
830 | - echo wp_kses_post( $output_pagination ); |
|
831 | - ?> |
|
821 | + if ( $show_pagination ) { |
|
822 | + $output_pagination = do_shortcode( '[facetwp pager="true"]' ); |
|
823 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
824 | + foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
825 | + if ( isset( $this->facet_data[ $facet ] ) && in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
826 | + $output_pagination = do_shortcode( '[facetwp facet="pager_"]' ); |
|
827 | + } |
|
828 | + } |
|
829 | + } |
|
830 | + echo wp_kses_post( $output_pagination ); |
|
831 | + ?> |
|
832 | 832 | <?php } ?> |
833 | 833 | </div> |
834 | 834 | </div> |
835 | 835 | </div> |
836 | 836 | <?php } |
837 | - } |
|
838 | - |
|
839 | - /** |
|
840 | - * Adds in the closing facetwp div |
|
841 | - * |
|
842 | - * @return void |
|
843 | - */ |
|
844 | - public function facetwp_tempate_open() { |
|
845 | - ?> |
|
837 | + } |
|
838 | + |
|
839 | + /** |
|
840 | + * Adds in the closing facetwp div |
|
841 | + * |
|
842 | + * @return void |
|
843 | + */ |
|
844 | + public function facetwp_tempate_open() { |
|
845 | + ?> |
|
846 | 846 | <div class="facetwp-template"> |
847 | 847 | <?php |
848 | - } |
|
849 | - |
|
850 | - /** |
|
851 | - * Adds in the closing facetwp div |
|
852 | - * |
|
853 | - * @return void |
|
854 | - */ |
|
855 | - public function facetwp_tempate_close() { |
|
856 | - ?> |
|
848 | + } |
|
849 | + |
|
850 | + /** |
|
851 | + * Adds in the closing facetwp div |
|
852 | + * |
|
853 | + * @return void |
|
854 | + */ |
|
855 | + public function facetwp_tempate_close() { |
|
856 | + ?> |
|
857 | 857 | </div> |
858 | 858 | <?php |
859 | - } |
|
860 | - |
|
861 | - /** |
|
862 | - * Disables default sidebar. |
|
863 | - */ |
|
864 | - public function lsx_sidebar_enable( $sidebar_enabled ) { |
|
865 | - $sidebar_enabled = false; |
|
866 | - return $sidebar_enabled; |
|
867 | - } |
|
868 | - |
|
869 | - /** |
|
870 | - * Outputs custom sidebar. |
|
871 | - */ |
|
872 | - public function search_sidebar() { |
|
873 | - |
|
874 | - $this->options = apply_filters( 'lsx_search_sidebar_options', $this->options ); |
|
875 | - ?> |
|
859 | + } |
|
860 | + |
|
861 | + /** |
|
862 | + * Disables default sidebar. |
|
863 | + */ |
|
864 | + public function lsx_sidebar_enable( $sidebar_enabled ) { |
|
865 | + $sidebar_enabled = false; |
|
866 | + return $sidebar_enabled; |
|
867 | + } |
|
868 | + |
|
869 | + /** |
|
870 | + * Outputs custom sidebar. |
|
871 | + */ |
|
872 | + public function search_sidebar() { |
|
873 | + |
|
874 | + $this->options = apply_filters( 'lsx_search_sidebar_options', $this->options ); |
|
875 | + ?> |
|
876 | 876 | <?php do_action( 'lsx_search_sidebar_before' ); ?> |
877 | 877 | |
878 | 878 | <div id="secondary" class="facetwp-sidebar widget-area <?php echo esc_attr( lsx_sidebar_class() ); ?>" role="complementary"> |
@@ -897,13 +897,13 @@ discard block |
||
897 | 897 | |
898 | 898 | <div class="row"> |
899 | 899 | <?php |
900 | - // Slider. |
|
901 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
902 | - if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'alpha', 'search', 'pager' ) ) ) { |
|
903 | - $this->display_facet_default( $facet ); |
|
904 | - } |
|
905 | - } |
|
906 | - ?> |
|
900 | + // Slider. |
|
901 | + foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
902 | + if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'alpha', 'search', 'pager' ) ) ) { |
|
903 | + $this->display_facet_default( $facet ); |
|
904 | + } |
|
905 | + } |
|
906 | + ?> |
|
907 | 907 | </div> |
908 | 908 | |
909 | 909 | <div class="row hidden-sm hidden-md hidden-lg ssm-row-margin-top"> |
@@ -920,35 +920,35 @@ discard block |
||
920 | 920 | |
921 | 921 | <?php do_action( 'lsx_search_sidebar_after' ); ?> |
922 | 922 | <?php |
923 | - } |
|
924 | - |
|
925 | - /** |
|
926 | - * Check if the pager facet is on |
|
927 | - * |
|
928 | - * @return void |
|
929 | - */ |
|
930 | - public function pager_facet_enabled() { |
|
931 | - |
|
932 | - $pager_facet_off = false; |
|
933 | - |
|
934 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
935 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
936 | - if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
937 | - $pager_facet_off = true; |
|
938 | - } |
|
939 | - } |
|
940 | - } |
|
941 | - |
|
942 | - return $pager_facet_off; |
|
943 | - } |
|
944 | - |
|
945 | - /** |
|
946 | - * Display WooCommerce archive title. |
|
947 | - */ |
|
948 | - public function wc_archive_header() { |
|
949 | - $default_size = 'sm'; |
|
950 | - $size = apply_filters( 'lsx_bootstrap_column_size', $default_size ); |
|
951 | - ?> |
|
923 | + } |
|
924 | + |
|
925 | + /** |
|
926 | + * Check if the pager facet is on |
|
927 | + * |
|
928 | + * @return void |
|
929 | + */ |
|
930 | + public function pager_facet_enabled() { |
|
931 | + |
|
932 | + $pager_facet_off = false; |
|
933 | + |
|
934 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
935 | + foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
936 | + if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
937 | + $pager_facet_off = true; |
|
938 | + } |
|
939 | + } |
|
940 | + } |
|
941 | + |
|
942 | + return $pager_facet_off; |
|
943 | + } |
|
944 | + |
|
945 | + /** |
|
946 | + * Display WooCommerce archive title. |
|
947 | + */ |
|
948 | + public function wc_archive_header() { |
|
949 | + $default_size = 'sm'; |
|
950 | + $size = apply_filters( 'lsx_bootstrap_column_size', $default_size ); |
|
951 | + ?> |
|
952 | 952 | <div class="archive-header-wrapper banner-woocommerce col-<?php echo esc_attr( $size ); ?>-12"> |
953 | 953 | <?php lsx_global_header_inner_bottom(); ?> |
954 | 954 | <header class="archive-header"> |
@@ -956,13 +956,13 @@ discard block |
||
956 | 956 | </header> |
957 | 957 | </div> |
958 | 958 | <?php |
959 | - } |
|
959 | + } |
|
960 | 960 | |
961 | - /** |
|
962 | - * Display facet search. |
|
963 | - */ |
|
964 | - public function display_facet_search() { |
|
965 | - ?> |
|
961 | + /** |
|
962 | + * Display facet search. |
|
963 | + */ |
|
964 | + public function display_facet_search() { |
|
965 | + ?> |
|
966 | 966 | <div class="col-xs-12 facetwp-item facetwp-form"> |
967 | 967 | <form class="search-form lsx-search-form" action="/" method="get"> |
968 | 968 | <div class="input-group"> |
@@ -977,17 +977,17 @@ discard block |
||
977 | 977 | </form> |
978 | 978 | </div> |
979 | 979 | <?php |
980 | - } |
|
980 | + } |
|
981 | 981 | |
982 | - /** |
|
983 | - * Display facet default. |
|
984 | - */ |
|
985 | - public function display_facet_default( $facet ) { |
|
982 | + /** |
|
983 | + * Display facet default. |
|
984 | + */ |
|
985 | + public function display_facet_default( $facet ) { |
|
986 | 986 | |
987 | - $show_collapse = ! isset( $this->options['display']['enable_collapse'] ) || 'on' !== $this->options['display']['enable_collapse']; |
|
988 | - $col_class = ''; |
|
987 | + $show_collapse = ! isset( $this->options['display']['enable_collapse'] ) || 'on' !== $this->options['display']['enable_collapse']; |
|
988 | + $col_class = ''; |
|
989 | 989 | |
990 | - if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?> |
|
990 | + if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?> |
|
991 | 991 | <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
992 | 992 | <?php else : ?> |
993 | 993 | <div class="col-xs-12 facetwp-item parent-facetwp-facet-<?php echo esc_html( $facet ); ?> <?php echo esc_attr( $col_class ); ?>"> |
@@ -1005,72 +1005,72 @@ discard block |
||
1005 | 1005 | <?php } ?> |
1006 | 1006 | </div> |
1007 | 1007 | <?php |
1008 | - endif; |
|
1009 | - } |
|
1010 | - |
|
1011 | - /** |
|
1012 | - * Changes slot column class. |
|
1013 | - */ |
|
1014 | - public function change_slot_column_class( $class ) { |
|
1015 | - if ( is_post_type_archive( 'video' ) || is_tax( 'video-category' ) ) { |
|
1016 | - $column_class = 'col-xs-12 col-sm-4'; |
|
1017 | - } |
|
1018 | - |
|
1019 | - return $column_class; |
|
1020 | - } |
|
1021 | - |
|
1022 | - /** |
|
1023 | - * Add post type label to the title. |
|
1024 | - */ |
|
1025 | - public function add_label_to_title() { |
|
1026 | - if ( is_search() ) { |
|
1027 | - if ( ! empty( $this->options['display']['engine_search_enable_pt_label'] ) ) { |
|
1028 | - $post_type = get_post_type(); |
|
1029 | - $post_type = str_replace( '_', ' ', $post_type ); |
|
1030 | - $post_type = str_replace( '-', ' ', $post_type ); |
|
1031 | - if ( 'tribe events' === $post_type ) { |
|
1032 | - $post_type = 'Events'; |
|
1033 | - } |
|
1034 | - echo wp_kses_post( ' <span class="label label-default lsx-label-post-type">' . $post_type . '</span>' ); |
|
1035 | - } |
|
1036 | - } |
|
1037 | - } |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * Changes the sort options. |
|
1041 | - */ |
|
1042 | - public function facetwp_sort_options( $options, $params ) { |
|
1043 | - $this->set_vars(); |
|
1044 | - |
|
1045 | - if ( true === $this->search_enabled ) { |
|
1046 | - if ( 'default' !== $params['template_name'] && 'wp' !== $params['template_name'] ) { |
|
1047 | - return $options; |
|
1048 | - } |
|
1049 | - |
|
1050 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_date_sorting' ] ) ) { |
|
1051 | - unset( $options['date_desc'] ); |
|
1052 | - unset( $options['date_asc'] ); |
|
1053 | - } |
|
1054 | - |
|
1055 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_az_sorting' ] ) ) { |
|
1056 | - unset( $options['title_desc'] ); |
|
1057 | - unset( $options['title_asc'] ); |
|
1058 | - } |
|
1059 | - } |
|
1060 | - |
|
1061 | - return $options; |
|
1062 | - } |
|
1063 | - |
|
1064 | - /** |
|
1065 | - * @param $allowedtags |
|
1066 | - * @param $context |
|
1067 | - * |
|
1068 | - * @return mixed |
|
1069 | - */ |
|
1070 | - public function kses_allowed_html( $allowedtags, $context ) { |
|
1071 | - $allowedtags['a']['data-value'] = true; |
|
1072 | - $allowedtags['a']['data-selection'] = true; |
|
1073 | - $allowedtags['button']['data-toggle'] = true; |
|
1074 | - return $allowedtags; |
|
1075 | - } |
|
1008 | + endif; |
|
1009 | + } |
|
1010 | + |
|
1011 | + /** |
|
1012 | + * Changes slot column class. |
|
1013 | + */ |
|
1014 | + public function change_slot_column_class( $class ) { |
|
1015 | + if ( is_post_type_archive( 'video' ) || is_tax( 'video-category' ) ) { |
|
1016 | + $column_class = 'col-xs-12 col-sm-4'; |
|
1017 | + } |
|
1018 | + |
|
1019 | + return $column_class; |
|
1020 | + } |
|
1021 | + |
|
1022 | + /** |
|
1023 | + * Add post type label to the title. |
|
1024 | + */ |
|
1025 | + public function add_label_to_title() { |
|
1026 | + if ( is_search() ) { |
|
1027 | + if ( ! empty( $this->options['display']['engine_search_enable_pt_label'] ) ) { |
|
1028 | + $post_type = get_post_type(); |
|
1029 | + $post_type = str_replace( '_', ' ', $post_type ); |
|
1030 | + $post_type = str_replace( '-', ' ', $post_type ); |
|
1031 | + if ( 'tribe events' === $post_type ) { |
|
1032 | + $post_type = 'Events'; |
|
1033 | + } |
|
1034 | + echo wp_kses_post( ' <span class="label label-default lsx-label-post-type">' . $post_type . '</span>' ); |
|
1035 | + } |
|
1036 | + } |
|
1037 | + } |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * Changes the sort options. |
|
1041 | + */ |
|
1042 | + public function facetwp_sort_options( $options, $params ) { |
|
1043 | + $this->set_vars(); |
|
1044 | + |
|
1045 | + if ( true === $this->search_enabled ) { |
|
1046 | + if ( 'default' !== $params['template_name'] && 'wp' !== $params['template_name'] ) { |
|
1047 | + return $options; |
|
1048 | + } |
|
1049 | + |
|
1050 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_date_sorting' ] ) ) { |
|
1051 | + unset( $options['date_desc'] ); |
|
1052 | + unset( $options['date_asc'] ); |
|
1053 | + } |
|
1054 | + |
|
1055 | + if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_az_sorting' ] ) ) { |
|
1056 | + unset( $options['title_desc'] ); |
|
1057 | + unset( $options['title_asc'] ); |
|
1058 | + } |
|
1059 | + } |
|
1060 | + |
|
1061 | + return $options; |
|
1062 | + } |
|
1063 | + |
|
1064 | + /** |
|
1065 | + * @param $allowedtags |
|
1066 | + * @param $context |
|
1067 | + * |
|
1068 | + * @return mixed |
|
1069 | + */ |
|
1070 | + public function kses_allowed_html( $allowedtags, $context ) { |
|
1071 | + $allowedtags['a']['data-value'] = true; |
|
1072 | + $allowedtags['a']['data-selection'] = true; |
|
1073 | + $allowedtags['button']['data-toggle'] = true; |
|
1074 | + return $allowedtags; |
|
1075 | + } |
|
1076 | 1076 | } |
@@ -70,26 +70,26 @@ 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' ) ); |
|
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 | 78 | |
79 | - add_action( 'pre_get_posts', array( $this, 'filter_post_types' ) ); |
|
79 | + add_action('pre_get_posts', array($this, 'filter_post_types')); |
|
80 | 80 | |
81 | - add_filter( 'lsx_search_post_types', array( $this, 'register_post_types' ) ); |
|
82 | - add_filter( 'lsx_search_taxonomies', array( $this, 'register_taxonomies' ) ); |
|
83 | - add_filter( 'lsx_search_post_types_plural', array( $this, 'register_post_type_tabs' ) ); |
|
84 | - add_filter( 'facetwp_sort_options', array( $this, 'facetwp_sort_options' ), 10, 2 ); |
|
85 | - add_filter( 'wp_kses_allowed_html', array( $this, 'kses_allowed_html' ), 20, 2 ); |
|
81 | + add_filter('lsx_search_post_types', array($this, 'register_post_types')); |
|
82 | + add_filter('lsx_search_taxonomies', array($this, 'register_taxonomies')); |
|
83 | + add_filter('lsx_search_post_types_plural', array($this, 'register_post_type_tabs')); |
|
84 | + add_filter('facetwp_sort_options', array($this, 'facetwp_sort_options'), 10, 2); |
|
85 | + add_filter('wp_kses_allowed_html', array($this, 'kses_allowed_html'), 20, 2); |
|
86 | 86 | |
87 | 87 | // Redirects. |
88 | - add_action( 'template_redirect', array( $this, 'pretty_search_redirect' ) ); |
|
89 | - add_filter( 'pre_get_posts', array( $this, 'pretty_search_parse_query' ) ); |
|
88 | + add_action('template_redirect', array($this, 'pretty_search_redirect')); |
|
89 | + add_filter('pre_get_posts', array($this, 'pretty_search_parse_query')); |
|
90 | 90 | |
91 | - add_action( 'lsx_search_sidebar_top', array( $this, 'search_sidebar_top' ) ); |
|
92 | - add_filter( 'facetwp_facet_html', array( $this, 'search_facet_html' ), 10, 2 ); |
|
91 | + add_action('lsx_search_sidebar_top', array($this, 'search_sidebar_top')); |
|
92 | + add_filter('facetwp_facet_html', array($this, 'search_facet_html'), 10, 2); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function get_instance() { |
103 | 103 | // If the single instance hasn't been set, set it now. |
104 | - if ( null === self::$instance ) { |
|
104 | + if (null === self::$instance) { |
|
105 | 105 | self::$instance = new self(); |
106 | 106 | } |
107 | 107 | return self::$instance; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * Loads the variable classes and the static classes. |
112 | 112 | */ |
113 | 113 | private function load_classes() { |
114 | - require_once LSX_SEARCH_PATH . 'classes/frontend/class-layout.php'; |
|
114 | + require_once LSX_SEARCH_PATH.'classes/frontend/class-layout.php'; |
|
115 | 115 | $this->layout = frontend\Layout::get_instance(); |
116 | 116 | } |
117 | 117 | |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | public function set_vars() { |
122 | 122 | $post_type = ''; |
123 | 123 | |
124 | - $this->post_types = apply_filters( 'lsx_search_post_types', array() ); |
|
125 | - $this->taxonomies = apply_filters( 'lsx_search_taxonomies', array() ); |
|
126 | - $this->tabs = apply_filters( 'lsx_search_post_types_plural', array() ); |
|
127 | - $this->options = apply_filters( 'lsx_search_options', $this->options ); |
|
124 | + $this->post_types = apply_filters('lsx_search_post_types', array()); |
|
125 | + $this->taxonomies = apply_filters('lsx_search_taxonomies', array()); |
|
126 | + $this->tabs = apply_filters('lsx_search_post_types_plural', array()); |
|
127 | + $this->options = apply_filters('lsx_search_options', $this->options); |
|
128 | 128 | $this->post_types = get_post_types(); |
129 | 129 | $this->post_type_slugs = array( |
130 | 130 | 'post' => 'posts', |
@@ -137,22 +137,22 @@ discard block |
||
137 | 137 | ); |
138 | 138 | $this->set_search_prefix(); |
139 | 139 | $this->get_cmb2_options(); |
140 | - $this->search_enabled = apply_filters( 'lsx_search_enabled', $this->is_search_enabled(), $this ); |
|
141 | - $this->search_prefix = apply_filters( 'lsx_search_prefix', $this->search_prefix, $this ); |
|
140 | + $this->search_enabled = apply_filters('lsx_search_enabled', $this->is_search_enabled(), $this); |
|
141 | + $this->search_prefix = apply_filters('lsx_search_prefix', $this->search_prefix, $this); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | private function get_cmb2_options() { |
145 | - $cmb2_options = get_option( 'lsx-search-settings' ); |
|
146 | - if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) { |
|
147 | - $this->set_search_prefix( true ); |
|
145 | + $cmb2_options = get_option('lsx-search-settings'); |
|
146 | + if (false !== $cmb2_options && !empty($cmb2_options)) { |
|
147 | + $this->set_search_prefix(true); |
|
148 | 148 | $this->options['display'] = $cmb2_options; |
149 | - foreach ( $this->options['display'] as $option_key => $option_value ) { |
|
150 | - if ( is_array( $option_value ) && ! empty( $option_value ) ) { |
|
149 | + foreach ($this->options['display'] as $option_key => $option_value) { |
|
150 | + if (is_array($option_value) && !empty($option_value)) { |
|
151 | 151 | $new_values = array(); |
152 | - foreach ( $option_value as $empty_key => $key_value ) { |
|
153 | - $new_values[ $key_value ] = 'on'; |
|
152 | + foreach ($option_value as $empty_key => $key_value) { |
|
153 | + $new_values[$key_value] = 'on'; |
|
154 | 154 | } |
155 | - $this->options['display'][ $option_key ] = $new_values; |
|
155 | + $this->options['display'][$option_key] = $new_values; |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | $this->new_options = true; |
@@ -162,46 +162,46 @@ discard block |
||
162 | 162 | |
163 | 163 | private function disable_to_search_actions() { |
164 | 164 | global $lsx_to_search_fwp, $lsx_to_search; |
165 | - if ( null !== $lsx_to_search ) { |
|
165 | + if (null !== $lsx_to_search) { |
|
166 | 166 | // Redirects. |
167 | - remove_filter( 'template_include', array( $lsx_to_search, 'search_template_include' ), 99 ); |
|
168 | - remove_action( 'template_redirect', array( $lsx_to_search, 'pretty_search_redirect' ) ); |
|
169 | - remove_filter( 'pre_get_posts', array( $lsx_to_search, 'pretty_search_parse_query' ) ); |
|
167 | + remove_filter('template_include', array($lsx_to_search, 'search_template_include'), 99); |
|
168 | + remove_action('template_redirect', array($lsx_to_search, 'pretty_search_redirect')); |
|
169 | + remove_filter('pre_get_posts', array($lsx_to_search, 'pretty_search_parse_query')); |
|
170 | 170 | |
171 | 171 | // Layout Filter. |
172 | - remove_filter( 'lsx_layout', array( $lsx_to_search, 'lsx_layout' ), 20, 1 ); |
|
173 | - remove_filter( 'lsx_layout_selector', array( $lsx_to_search, 'lsx_layout_selector' ), 10, 4 ); |
|
174 | - remove_filter( 'lsx_to_archive_layout', array( $lsx_to_search, 'lsx_to_search_archive_layout' ), 10, 2 ); |
|
172 | + remove_filter('lsx_layout', array($lsx_to_search, 'lsx_layout'), 20, 1); |
|
173 | + remove_filter('lsx_layout_selector', array($lsx_to_search, 'lsx_layout_selector'), 10, 4); |
|
174 | + remove_filter('lsx_to_archive_layout', array($lsx_to_search, 'lsx_to_search_archive_layout'), 10, 2); |
|
175 | 175 | |
176 | - remove_action( 'lsx_search_sidebar_top', array( $lsx_to_search, 'search_sidebar_top' ) ); |
|
177 | - remove_action( 'pre_get_posts', array( $lsx_to_search, 'price_sorting' ), 100 ); |
|
176 | + remove_action('lsx_search_sidebar_top', array($lsx_to_search, 'search_sidebar_top')); |
|
177 | + remove_action('pre_get_posts', array($lsx_to_search, 'price_sorting'), 100); |
|
178 | 178 | |
179 | 179 | //add_shortcode( 'lsx_search_form', array( 'LSX_TO_Search_Frontend', 'search_form' ) ); |
180 | - remove_filter( 'searchwp_short_circuit', array( $lsx_to_search, 'searchwp_short_circuit' ), 10, 2 ); |
|
181 | - remove_filter( 'get_search_query', array( $lsx_to_search, 'get_search_query' ) ); |
|
182 | - remove_filter( 'body_class', array( $lsx_to_search, 'to_add_search_url_class' ), 20 ); |
|
180 | + remove_filter('searchwp_short_circuit', array($lsx_to_search, 'searchwp_short_circuit'), 10, 2); |
|
181 | + remove_filter('get_search_query', array($lsx_to_search, 'get_search_query')); |
|
182 | + remove_filter('body_class', array($lsx_to_search, 'to_add_search_url_class'), 20); |
|
183 | 183 | |
184 | - remove_filter( 'facetwp_preload_url_vars', array( $lsx_to_search, 'preload_url_vars' ), 10, 1 ); |
|
185 | - remove_filter( 'wpseo_json_ld_search_url', array( $lsx_to_search, 'change_json_ld_search_url' ), 10, 1 ); |
|
184 | + remove_filter('facetwp_preload_url_vars', array($lsx_to_search, 'preload_url_vars'), 10, 1); |
|
185 | + remove_filter('wpseo_json_ld_search_url', array($lsx_to_search, 'change_json_ld_search_url'), 10, 1); |
|
186 | 186 | } |
187 | - if ( null !== $lsx_to_search_fwp ) { |
|
188 | - remove_filter( 'facetwp_indexer_row_data', array( $lsx_to_search_fwp, 'facetwp_index_row_data' ), 10, 2 ); |
|
189 | - remove_filter( 'facetwp_index_row', array( $lsx_to_search_fwp, 'facetwp_index_row' ), 10, 2 ); |
|
187 | + if (null !== $lsx_to_search_fwp) { |
|
188 | + remove_filter('facetwp_indexer_row_data', array($lsx_to_search_fwp, 'facetwp_index_row_data'), 10, 2); |
|
189 | + remove_filter('facetwp_index_row', array($lsx_to_search_fwp, 'facetwp_index_row'), 10, 2); |
|
190 | 190 | |
191 | - remove_filter( 'facetwp_sort_options', array( $lsx_to_search_fwp, 'facet_sort_options' ), 10, 2 ); |
|
191 | + remove_filter('facetwp_sort_options', array($lsx_to_search_fwp, 'facet_sort_options'), 10, 2); |
|
192 | 192 | |
193 | - remove_filter( 'facetwp_pager_html', array( $lsx_to_search_fwp, 'facetwp_pager_html' ), 10, 2 ); |
|
194 | - remove_filter( 'facetwp_result_count', array( $lsx_to_search_fwp, 'facetwp_result_count' ), 10, 2 ); |
|
193 | + remove_filter('facetwp_pager_html', array($lsx_to_search_fwp, 'facetwp_pager_html'), 10, 2); |
|
194 | + remove_filter('facetwp_result_count', array($lsx_to_search_fwp, 'facetwp_result_count'), 10, 2); |
|
195 | 195 | |
196 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'destination_facet_html' ), 10, 2 ); |
|
197 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'slide_facet_html' ), 10, 2 ); |
|
198 | - remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'search_facet_html' ), 10, 2 ); |
|
199 | - remove_filter( 'facetwp_load_css', array( $lsx_to_search_fwp, 'facetwp_load_css' ), 10, 1 ); |
|
196 | + remove_filter('facetwp_facet_html', array($lsx_to_search_fwp, 'destination_facet_html'), 10, 2); |
|
197 | + remove_filter('facetwp_facet_html', array($lsx_to_search_fwp, 'slide_facet_html'), 10, 2); |
|
198 | + remove_filter('facetwp_facet_html', array($lsx_to_search_fwp, 'search_facet_html'), 10, 2); |
|
199 | + remove_filter('facetwp_load_css', array($lsx_to_search_fwp, 'facetwp_load_css'), 10, 1); |
|
200 | 200 | |
201 | - if ( class_exists( 'LSX_Currencies' ) ) { |
|
202 | - remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_lsx_currencies' ), 10, 2 ); |
|
201 | + if (class_exists('LSX_Currencies')) { |
|
202 | + remove_filter('facetwp_render_output', array($lsx_to_search_fwp, 'slide_price_lsx_currencies'), 10, 2); |
|
203 | 203 | } else { |
204 | - remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_to_currencies' ), 10, 2 ); |
|
204 | + remove_filter('facetwp_render_output', array($lsx_to_search_fwp, 'slide_price_to_currencies'), 10, 2); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | } |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | public function is_search_enabled() { |
215 | 215 | $search_enabled = false; |
216 | 216 | |
217 | - if ( false === $this->new_options ) { |
|
218 | - 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 ] ) { |
|
217 | + if (false === $this->new_options) { |
|
218 | + 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 | 219 | $search_enabled = true; |
220 | 220 | } |
221 | 221 | } else { |
222 | 222 | $enable_prefix = $this->search_prefix; |
223 | - if ( ! empty( $this->options ) && isset( $this->options['display'] ) && isset( $this->options['display'][ $enable_prefix . '_enable' ] ) && 'on' === $this->options['display'][ $enable_prefix . '_enable' ] ) { |
|
223 | + if (!empty($this->options) && isset($this->options['display']) && isset($this->options['display'][$enable_prefix.'_enable']) && 'on' === $this->options['display'][$enable_prefix.'_enable']) { |
|
224 | 224 | $search_enabled = true; |
225 | 225 | } |
226 | 226 | } |
@@ -232,44 +232,44 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return void |
234 | 234 | */ |
235 | - private function set_search_prefix( $new_prefixes = false ) { |
|
236 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
237 | - if ( false !== $new_prefixes ) { |
|
235 | + private function set_search_prefix($new_prefixes = false) { |
|
236 | + $page_for_posts = get_option('page_for_posts'); |
|
237 | + if (false !== $new_prefixes) { |
|
238 | 238 | $this->taxonomies = array(); |
239 | 239 | $this->post_types = array(); |
240 | 240 | } |
241 | 241 | |
242 | - if ( is_search() ) { |
|
243 | - if ( false === $new_prefixes ) { |
|
242 | + if (is_search()) { |
|
243 | + if (false === $new_prefixes) { |
|
244 | 244 | $this->search_core_suffix = 'core'; |
245 | 245 | $this->search_prefix = 'search'; |
246 | 246 | } else { |
247 | 247 | $this->search_core_suffix = 'enable'; |
248 | 248 | $this->search_prefix = 'engine_search'; |
249 | 249 | } |
250 | - } elseif ( is_post_type_archive( $this->post_types ) || is_tax() || is_page( $page_for_posts ) || is_home() || is_category() || is_tag() ) { |
|
251 | - if ( false === $new_prefixes ) { |
|
250 | + } elseif (is_post_type_archive($this->post_types) || is_tax() || is_page($page_for_posts) || is_home() || is_category() || is_tag()) { |
|
251 | + if (false === $new_prefixes) { |
|
252 | 252 | $this->search_core_suffix = 'search'; |
253 | 253 | } else { |
254 | 254 | $this->search_core_suffix = 'enable'; |
255 | 255 | } |
256 | 256 | |
257 | - if ( is_tax() ) { |
|
258 | - $tax = get_query_var( 'taxonomy' ); |
|
259 | - $tax = get_taxonomy( $tax ); |
|
257 | + if (is_tax()) { |
|
258 | + $tax = get_query_var('taxonomy'); |
|
259 | + $tax = get_taxonomy($tax); |
|
260 | 260 | $post_type = $tax->object_type[0]; |
261 | - } else if ( is_page( $page_for_posts ) || is_category() || is_tag() || is_home() ) { |
|
261 | + } else if (is_page($page_for_posts) || is_category() || is_tag() || is_home()) { |
|
262 | 262 | $post_type = 'post'; |
263 | 263 | } else { |
264 | - $post_type = get_query_var( 'post_type' ); |
|
264 | + $post_type = get_query_var('post_type'); |
|
265 | 265 | } |
266 | 266 | |
267 | - if ( false === $new_prefixes ) { |
|
268 | - if ( isset( $this->tabs[ $post_type ] ) ) { |
|
269 | - $this->search_prefix = $this->tabs[ $post_type ] . '_archive'; |
|
267 | + if (false === $new_prefixes) { |
|
268 | + if (isset($this->tabs[$post_type])) { |
|
269 | + $this->search_prefix = $this->tabs[$post_type].'_archive'; |
|
270 | 270 | } |
271 | 271 | } else { |
272 | - $this->search_prefix = $post_type . '_search'; |
|
272 | + $this->search_prefix = $post_type.'_search'; |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function set_facetwp_vars() { |
281 | 281 | |
282 | - if ( class_exists( 'FacetWP' ) ) { |
|
282 | + if (class_exists('FacetWP')) { |
|
283 | 283 | $facet_data = FWP()->helper->get_facets(); |
284 | 284 | } |
285 | 285 | |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | |
288 | 288 | $this->facet_data['search_form'] = array( |
289 | 289 | 'name' => 'search_form', |
290 | - 'label' => esc_html__( 'Search Form', 'lsx-search' ), |
|
290 | + 'label' => esc_html__('Search Form', 'lsx-search'), |
|
291 | 291 | ); |
292 | 292 | |
293 | - if ( ! empty( $facet_data ) && is_array( $facet_data ) ) { |
|
294 | - foreach ( $facet_data as $facet ) { |
|
295 | - $this->facet_data[ $facet['name'] ] = $facet; |
|
293 | + if (!empty($facet_data) && is_array($facet_data)) { |
|
294 | + foreach ($facet_data as $facet) { |
|
295 | + $this->facet_data[$facet['name']] = $facet; |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | } |
@@ -302,61 +302,61 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function core() { |
304 | 304 | |
305 | - if ( true === $this->search_enabled ) { |
|
306 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 999 ); |
|
305 | + if (true === $this->search_enabled) { |
|
306 | + add_action('wp_enqueue_scripts', array($this, 'assets'), 999); |
|
307 | 307 | |
308 | - add_filter( 'lsx_layout', array( $this, 'lsx_layout' ), 20, 1 ); |
|
309 | - add_filter( 'lsx_layout_selector', array( $this, 'lsx_layout_selector' ), 10, 4 ); |
|
310 | - add_filter( 'lsx_slot_class', array( $this, 'change_slot_column_class' ) ); |
|
311 | - add_action( 'lsx_entry_top', array( $this, 'add_label_to_title' ) ); |
|
312 | - add_filter( 'body_class', array( $this, 'body_class' ), 10 ); |
|
308 | + add_filter('lsx_layout', array($this, 'lsx_layout'), 20, 1); |
|
309 | + add_filter('lsx_layout_selector', array($this, 'lsx_layout_selector'), 10, 4); |
|
310 | + add_filter('lsx_slot_class', array($this, 'change_slot_column_class')); |
|
311 | + add_action('lsx_entry_top', array($this, 'add_label_to_title')); |
|
312 | + add_filter('body_class', array($this, 'body_class'), 10); |
|
313 | 313 | |
314 | - add_filter( 'lsx_blog_customizer_top_of_blog_action', array( $this, 'top_of_blog_action' ), 10, 1 ); |
|
315 | - add_filter( 'lsx_blog_customizer_blog_description_class', array( $this, 'blog_description_class' ), 10, 1 ); |
|
314 | + add_filter('lsx_blog_customizer_top_of_blog_action', array($this, 'top_of_blog_action'), 10, 1); |
|
315 | + add_filter('lsx_blog_customizer_blog_description_class', array($this, 'blog_description_class'), 10, 1); |
|
316 | 316 | |
317 | - if ( class_exists( 'LSX_Videos' ) ) { |
|
317 | + if (class_exists('LSX_Videos')) { |
|
318 | 318 | global $lsx_videos_frontend; |
319 | - remove_action( 'lsx_content_top', array( $lsx_videos_frontend, 'categories_tabs' ), 15 ); |
|
319 | + remove_action('lsx_content_top', array($lsx_videos_frontend, 'categories_tabs'), 15); |
|
320 | 320 | } |
321 | 321 | |
322 | - add_filter( 'lsx_paging_nav_disable', '__return_true' ); |
|
323 | - add_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
324 | - add_action( 'lsx_content_top', array( $this, 'facetwp_tempate_open' ) ); |
|
325 | - add_action( 'lsx_content_bottom', array( $this, 'facetwp_tempate_close' ) ); |
|
326 | - add_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
322 | + add_filter('lsx_paging_nav_disable', '__return_true'); |
|
323 | + add_action('lsx_content_top', array($this, 'facet_top_bar')); |
|
324 | + add_action('lsx_content_top', array($this, 'facetwp_tempate_open')); |
|
325 | + add_action('lsx_content_bottom', array($this, 'facetwp_tempate_close')); |
|
326 | + add_action('lsx_content_bottom', array($this, 'facet_bottom_bar')); |
|
327 | 327 | |
328 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) && '1c' !== $this->options['display'][ $this->search_prefix . '_layout' ] ) { |
|
329 | - add_filter( 'lsx_sidebar_enable', array( $this, 'lsx_sidebar_enable' ), 10, 1 ); |
|
328 | + if (!empty($this->options['display'][$this->search_prefix.'_layout']) && '1c' !== $this->options['display'][$this->search_prefix.'_layout']) { |
|
329 | + add_filter('lsx_sidebar_enable', array($this, 'lsx_sidebar_enable'), 10, 1); |
|
330 | 330 | } |
331 | 331 | |
332 | - add_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
332 | + add_action('lsx_content_wrap_before', array($this, 'search_sidebar'), 150); |
|
333 | 333 | |
334 | - if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) { |
|
335 | - remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' ); |
|
336 | - remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' ); |
|
337 | - add_filter( 'woocommerce_show_page_title', '__return_false' ); |
|
334 | + if (class_exists('WooCommerce') && (is_shop() || is_product_category() || is_product_tag())) { |
|
335 | + remove_action('woocommerce_archive_description', 'woocommerce_taxonomy_archive_description'); |
|
336 | + remove_action('woocommerce_archive_description', 'woocommerce_product_archive_description'); |
|
337 | + add_filter('woocommerce_show_page_title', '__return_false'); |
|
338 | 338 | |
339 | - add_filter( 'loop_shop_columns', function() { |
|
339 | + add_filter('loop_shop_columns', function() { |
|
340 | 340 | return 3; |
341 | 341 | } ); |
342 | 342 | |
343 | 343 | // Actions added by LSX theme |
344 | - remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
|
345 | - add_action( 'lsx_content_wrap_before', array( $this, 'wc_archive_header' ), 140 ); |
|
344 | + remove_action('lsx_content_wrap_before', 'lsx_global_header'); |
|
345 | + add_action('lsx_content_wrap_before', array($this, 'wc_archive_header'), 140); |
|
346 | 346 | |
347 | 347 | // Actions added be LSX theme / woocommerce.php file |
348 | - remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
349 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
350 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 ); |
|
351 | - remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 ); |
|
352 | - remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
348 | + remove_action('woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9); |
|
349 | + remove_action('woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10); |
|
350 | + remove_action('woocommerce_after_shop_loop', 'woocommerce_result_count', 20); |
|
351 | + remove_action('woocommerce_after_shop_loop', 'woocommerce_pagination', 30); |
|
352 | + remove_action('woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31); |
|
353 | 353 | |
354 | 354 | // Actions added be LSX theme / woocommerce.php file |
355 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 ); |
|
356 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 ); |
|
357 | - remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 ); |
|
358 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 ); |
|
359 | - remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 ); |
|
355 | + remove_action('woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9); |
|
356 | + remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10); |
|
357 | + remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20); |
|
358 | + remove_action('woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30); |
|
359 | + remove_action('woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @param array $classes The classes. |
368 | 368 | * @return array $classes The classes. |
369 | 369 | */ |
370 | - public function body_class( $classes ) { |
|
370 | + public function body_class($classes) { |
|
371 | 371 | $classes[] = 'lsx-search-enabled'; |
372 | 372 | return $classes; |
373 | 373 | } |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @param string $action |
379 | 379 | * @return string $action |
380 | 380 | */ |
381 | - public function top_of_blog_action( $action = '' ) { |
|
381 | + public function top_of_blog_action($action = '') { |
|
382 | 382 | $action = 'lsx_content_wrap_before'; |
383 | 383 | return $action; |
384 | 384 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @param string $action |
390 | 390 | * @return string $action |
391 | 391 | */ |
392 | - public function blog_description_class( $class = '' ) { |
|
392 | + public function blog_description_class($class = '') { |
|
393 | 393 | $class .= ' col-md-12 search-description'; |
394 | 394 | return $class; |
395 | 395 | } |
@@ -400,13 +400,13 @@ discard block |
||
400 | 400 | * @return void |
401 | 401 | */ |
402 | 402 | public function check_for_results() { |
403 | - if ( true === $this->search_enabled ) { |
|
403 | + if (true === $this->search_enabled) { |
|
404 | 404 | global $wp_query; |
405 | - if ( empty( $wp_query->posts ) ) { |
|
405 | + if (empty($wp_query->posts)) { |
|
406 | 406 | $this->has_posts = false; |
407 | - remove_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) ); |
|
408 | - remove_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) ); |
|
409 | - remove_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 ); |
|
407 | + remove_action('lsx_content_top', array($this, 'facet_top_bar')); |
|
408 | + remove_action('lsx_content_bottom', array($this, 'facet_bottom_bar')); |
|
409 | + remove_action('lsx_content_wrap_before', array($this, 'search_sidebar'), 150); |
|
410 | 410 | } else { |
411 | 411 | $this->has_posts = true; |
412 | 412 | } |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | /** |
417 | 417 | * Filter the post types. |
418 | 418 | */ |
419 | - public function filter_post_types( $query ) { |
|
420 | - if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { |
|
421 | - if ( ! empty( $this->options ) && ! empty( $this->options['display']['search_enable_core'] ) ) { |
|
422 | - if ( ! empty( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
423 | - $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
424 | - $query->set( 'post_type', $post_types ); |
|
419 | + public function filter_post_types($query) { |
|
420 | + if (!is_admin() && $query->is_main_query() && $query->is_search()) { |
|
421 | + if (!empty($this->options) && !empty($this->options['display']['search_enable_core'])) { |
|
422 | + if (!empty($this->options['general']['search_post_types']) && is_array($this->options['general']['search_post_types'])) { |
|
423 | + $post_types = array_keys($this->options['general']['search_post_types']); |
|
424 | + $query->set('post_type', $post_types); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | } |
@@ -430,23 +430,23 @@ discard block |
||
430 | 430 | /** |
431 | 431 | * Sets post types with active search options. |
432 | 432 | */ |
433 | - public function register_post_types( $post_types ) { |
|
434 | - $post_types = array( 'post', 'project', 'service', 'team', 'testimonial', 'video', 'product' ); |
|
433 | + public function register_post_types($post_types) { |
|
434 | + $post_types = array('post', 'project', 'service', 'team', 'testimonial', 'video', 'product'); |
|
435 | 435 | return $post_types; |
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
439 | 439 | * Sets taxonomies with active search options. |
440 | 440 | */ |
441 | - public function register_taxonomies( $taxonomies ) { |
|
442 | - $taxonomies = array( 'category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag' ); |
|
441 | + public function register_taxonomies($taxonomies) { |
|
442 | + $taxonomies = array('category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag'); |
|
443 | 443 | return $taxonomies; |
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
447 | 447 | * Sets post types with active search options. |
448 | 448 | */ |
449 | - public function register_post_type_tabs( $post_types_plural ) { |
|
449 | + public function register_post_type_tabs($post_types_plural) { |
|
450 | 450 | $post_types_plural = array( |
451 | 451 | 'post' => 'posts', |
452 | 452 | 'project' => 'projects', |
@@ -463,23 +463,23 @@ discard block |
||
463 | 463 | * Enqueue styles and scripts. |
464 | 464 | */ |
465 | 465 | public function assets() { |
466 | - add_filter( 'lsx_defer_parsing_of_js', array( $this, 'skip_js_defer' ), 10, 4 ); |
|
467 | - wp_enqueue_script( 'touchSwipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.touchSwipe.min.js', array( 'jquery' ), LSX_SEARCH_VER, true ); |
|
468 | - wp_enqueue_script( 'slideandswipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.slideandswipe.min.js', array( 'jquery', 'touchSwipe' ), LSX_SEARCH_VER, true ); |
|
469 | - 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 ); |
|
466 | + add_filter('lsx_defer_parsing_of_js', array($this, 'skip_js_defer'), 10, 4); |
|
467 | + wp_enqueue_script('touchSwipe', LSX_SEARCH_URL.'assets/js/vendor/jquery.touchSwipe.min.js', array('jquery'), LSX_SEARCH_VER, true); |
|
468 | + wp_enqueue_script('slideandswipe', LSX_SEARCH_URL.'assets/js/vendor/jquery.slideandswipe.min.js', array('jquery', 'touchSwipe'), LSX_SEARCH_VER, true); |
|
469 | + 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); |
|
470 | 470 | |
471 | - $params = apply_filters( 'lsx_search_js_params', array( |
|
472 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
471 | + $params = apply_filters('lsx_search_js_params', array( |
|
472 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
473 | 473 | )); |
474 | 474 | |
475 | - wp_localize_script( 'lsx-search', 'lsx_customizer_params', $params ); |
|
475 | + wp_localize_script('lsx-search', 'lsx_customizer_params', $params); |
|
476 | 476 | |
477 | - wp_enqueue_style( 'lsx-search', LSX_SEARCH_URL . 'assets/css/lsx-search.css', array(), LSX_SEARCH_VER ); |
|
478 | - wp_style_add_data( 'lsx-search', 'rtl', 'replace' ); |
|
477 | + wp_enqueue_style('lsx-search', LSX_SEARCH_URL.'assets/css/lsx-search.css', array(), LSX_SEARCH_VER); |
|
478 | + wp_style_add_data('lsx-search', 'rtl', 'replace'); |
|
479 | 479 | |
480 | - if ( true === $this->new_options ) { |
|
481 | - wp_deregister_style( 'lsx_to_search' ); |
|
482 | - wp_deregister_script( 'lsx_to_search' ); |
|
480 | + if (true === $this->new_options) { |
|
481 | + wp_deregister_style('lsx_to_search'); |
|
482 | + wp_deregister_script('lsx_to_search'); |
|
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
@@ -492,8 +492,8 @@ discard block |
||
492 | 492 | * @param string $href |
493 | 493 | * @return boolean |
494 | 494 | */ |
495 | - public function skip_js_defer( $should_skip, $tag, $handle, $href ) { |
|
496 | - if ( ! is_admin() && ( false !== stripos( $href, 'lsx-search.min.js' ) || false !== stripos( $href, 'lsx-search.js' ) ) ) { |
|
495 | + public function skip_js_defer($should_skip, $tag, $handle, $href) { |
|
496 | + if (!is_admin() && (false !== stripos($href, 'lsx-search.min.js') || false !== stripos($href, 'lsx-search.js'))) { |
|
497 | 497 | $should_skip = true; |
498 | 498 | } |
499 | 499 | return $should_skip; |
@@ -505,10 +505,10 @@ discard block |
||
505 | 505 | * @param $template |
506 | 506 | * @return $template |
507 | 507 | */ |
508 | - public function search_template_include( $template ) { |
|
509 | - if ( is_main_query() && is_search() ) { |
|
510 | - if ( file_exists( LSX_SEARCH_PATH . 'templates/search.php' ) ) { |
|
511 | - $template = LSX_SEARCH_PATH . 'templates/search.php'; |
|
508 | + public function search_template_include($template) { |
|
509 | + if (is_main_query() && is_search()) { |
|
510 | + if (file_exists(LSX_SEARCH_PATH.'templates/search.php')) { |
|
511 | + $template = LSX_SEARCH_PATH.'templates/search.php'; |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
@@ -519,44 +519,44 @@ discard block |
||
519 | 519 | * Rewrite the search URL |
520 | 520 | */ |
521 | 521 | public function pretty_search_redirect() { |
522 | - global $wp_rewrite,$wp_query; |
|
522 | + global $wp_rewrite, $wp_query; |
|
523 | 523 | |
524 | - if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) { |
|
524 | + if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { |
|
525 | 525 | return; |
526 | 526 | } |
527 | 527 | |
528 | 528 | $search_base = $wp_rewrite->search_base; |
529 | 529 | |
530 | - if ( is_search() && ! is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) { |
|
531 | - $search_query = get_query_var( 's' ); |
|
530 | + if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) { |
|
531 | + $search_query = get_query_var('s'); |
|
532 | 532 | $engine = ''; |
533 | 533 | |
534 | 534 | // If the search was triggered by a supplemental engine. |
535 | - if ( isset( $_GET['engine'] ) && 'default' !== $_GET['engine'] ) { |
|
535 | + if (isset($_GET['engine']) && 'default' !== $_GET['engine']) { |
|
536 | 536 | $engine = $_GET['engine']; |
537 | - set_query_var( 'engine', $engine ); |
|
538 | - $engine = array_search( $engine, $this->post_type_slugs, true ) . '/'; |
|
537 | + set_query_var('engine', $engine); |
|
538 | + $engine = array_search($engine, $this->post_type_slugs, true).'/'; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | $get_array = $_GET; |
542 | 542 | |
543 | - if ( is_array( $get_array ) && ! empty( $get_array ) ) { |
|
543 | + if (is_array($get_array) && !empty($get_array)) { |
|
544 | 544 | $vars_to_maintain = array(); |
545 | 545 | |
546 | - foreach ( $get_array as $ga_key => $ga_value ) { |
|
547 | - if ( false !== strpos( $ga_key, 'fwp_' ) ) { |
|
548 | - $vars_to_maintain[] = $ga_key . '=' . $ga_value; |
|
546 | + foreach ($get_array as $ga_key => $ga_value) { |
|
547 | + if (false !== strpos($ga_key, 'fwp_')) { |
|
548 | + $vars_to_maintain[] = $ga_key.'='.$ga_value; |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
553 | - $redirect_url = home_url( "/{$search_base}/" . $engine . urlencode( $search_query ) ); |
|
553 | + $redirect_url = home_url("/{$search_base}/".$engine.urlencode($search_query)); |
|
554 | 554 | |
555 | - if ( ! empty( $vars_to_maintain ) ) { |
|
556 | - $redirect_url .= '?' . implode( '&', $vars_to_maintain ); |
|
555 | + if (!empty($vars_to_maintain)) { |
|
556 | + $redirect_url .= '?'.implode('&', $vars_to_maintain); |
|
557 | 557 | } |
558 | 558 | |
559 | - wp_redirect( $redirect_url ); |
|
559 | + wp_redirect($redirect_url); |
|
560 | 560 | exit(); |
561 | 561 | } |
562 | 562 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | /** |
565 | 565 | * Parse the Query and trigger a search |
566 | 566 | */ |
567 | - public function pretty_search_parse_query( $query ) { |
|
567 | + public function pretty_search_parse_query($query) { |
|
568 | 568 | $this->post_type_slugs = array( |
569 | 569 | 'post' => 'posts', |
570 | 570 | 'project' => 'projects', |
@@ -574,26 +574,26 @@ discard block |
||
574 | 574 | 'video' => 'videos', |
575 | 575 | 'product' => 'products', // WooCommerce |
576 | 576 | ); |
577 | - if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) { |
|
578 | - $search_query = $query->get( 's' ); |
|
579 | - $keyword_test = explode( '/', $search_query ); |
|
577 | + if ($query->is_search() && !is_admin() && $query->is_main_query()) { |
|
578 | + $search_query = $query->get('s'); |
|
579 | + $keyword_test = explode('/', $search_query); |
|
580 | 580 | |
581 | - $index = array_search( $keyword_test[0], $this->post_type_slugs, true ); |
|
582 | - if ( false !== $index ) { |
|
583 | - $engine = $this->post_type_slugs[ $index ]; |
|
581 | + $index = array_search($keyword_test[0], $this->post_type_slugs, true); |
|
582 | + if (false !== $index) { |
|
583 | + $engine = $this->post_type_slugs[$index]; |
|
584 | 584 | |
585 | - $query->set( 'post_type', $engine ); |
|
586 | - $query->set( 'engine', $engine ); |
|
585 | + $query->set('post_type', $engine); |
|
586 | + $query->set('engine', $engine); |
|
587 | 587 | |
588 | - if ( count( $keyword_test ) > 1 ) { |
|
589 | - $query->set( 's', $keyword_test[1] ); |
|
590 | - } elseif ( post_type_exists( $engine ) ) { |
|
591 | - $query->set( 's', '' ); |
|
588 | + if (count($keyword_test) > 1) { |
|
589 | + $query->set('s', $keyword_test[1]); |
|
590 | + } elseif (post_type_exists($engine)) { |
|
591 | + $query->set('s', ''); |
|
592 | 592 | } |
593 | 593 | } else { |
594 | - if ( isset( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) { |
|
595 | - $post_types = array_keys( $this->options['general']['search_post_types'] ); |
|
596 | - $query->set( 'post_type', $post_types ); |
|
594 | + if (isset($this->options['general']['search_post_types']) && is_array($this->options['general']['search_post_types'])) { |
|
595 | + $post_types = array_keys($this->options['general']['search_post_types']); |
|
596 | + $query->set('post_type', $post_types); |
|
597 | 597 | } |
598 | 598 | } |
599 | 599 | } |
@@ -607,18 +607,18 @@ discard block |
||
607 | 607 | * @return url |
608 | 608 | */ |
609 | 609 | public function change_json_ld_search_url() { |
610 | - return trailingslashit( home_url() ) . 'search/{search_term_string}'; |
|
610 | + return trailingslashit(home_url()).'search/{search_term_string}'; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | 614 | * A filter to set the layout to 2 column. |
615 | 615 | */ |
616 | - public function lsx_layout( $layout ) { |
|
617 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
618 | - if ( false === $this->has_posts ) { |
|
616 | + public function lsx_layout($layout) { |
|
617 | + if (!empty($this->options['display'][$this->search_prefix.'_layout'])) { |
|
618 | + if (false === $this->has_posts) { |
|
619 | 619 | $layout = '1c'; |
620 | 620 | } else { |
621 | - $layout = $this->options['display'][ $this->search_prefix . '_layout' ]; |
|
621 | + $layout = $this->options['display'][$this->search_prefix.'_layout']; |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | return $layout; |
@@ -628,23 +628,23 @@ discard block |
||
628 | 628 | * Outputs the Search Title Facet |
629 | 629 | */ |
630 | 630 | public function search_sidebar_top() { |
631 | - 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 ) ) { |
|
631 | + 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)) { |
|
632 | 632 | |
633 | - if ( ! is_search() ) { |
|
633 | + if (!is_search()) { |
|
634 | 634 | |
635 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
635 | + foreach ($this->options['display'][$this->search_prefix.'_facets'] as $facet => $facet_useless) { |
|
636 | 636 | |
637 | - if ( isset( $this->facet_data[ $facet ] ) && 'search' === $this->facet_data[ $facet ]['type'] ) { |
|
638 | - echo wp_kses_post( '<div class="row">' ); |
|
639 | - $this->display_facet_default( $facet ); |
|
640 | - echo wp_kses_post( '</div>' ); |
|
641 | - unset( $this->options['display'][ $this->search_prefix . '_facets' ][ $facet ] ); |
|
637 | + if (isset($this->facet_data[$facet]) && 'search' === $this->facet_data[$facet]['type']) { |
|
638 | + echo wp_kses_post('<div class="row">'); |
|
639 | + $this->display_facet_default($facet); |
|
640 | + echo wp_kses_post('</div>'); |
|
641 | + unset($this->options['display'][$this->search_prefix.'_facets'][$facet]); |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | } else { |
645 | - echo wp_kses_post( '<div class="row">' ); |
|
645 | + echo wp_kses_post('<div class="row">'); |
|
646 | 646 | $this->display_facet_search(); |
647 | - echo wp_kses_post( '</div>' ); |
|
647 | + echo wp_kses_post('</div>'); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |
@@ -656,13 +656,13 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @return string |
658 | 658 | */ |
659 | - public function search_facet_html( $output, $params ) { |
|
660 | - if ( 'search' == $params['facet']['type'] ) { |
|
659 | + public function search_facet_html($output, $params) { |
|
660 | + if ('search' == $params['facet']['type']) { |
|
661 | 661 | |
662 | 662 | $value = (array) $params['selected_values']; |
663 | - $value = empty( $value ) ? '' : stripslashes( $value[0] ); |
|
664 | - $placeholder = isset( $params['facet']['placeholder'] ) ? $params['facet']['placeholder'] : __( 'Search...', 'lsx-search' ); |
|
665 | - $placeholder = facetwp_i18n( $placeholder ); |
|
663 | + $value = empty($value) ? '' : stripslashes($value[0]); |
|
664 | + $placeholder = isset($params['facet']['placeholder']) ? $params['facet']['placeholder'] : __('Search...', 'lsx-search'); |
|
665 | + $placeholder = facetwp_i18n($placeholder); |
|
666 | 666 | |
667 | 667 | ob_start(); |
668 | 668 | ?> |
@@ -670,11 +670,11 @@ discard block |
||
670 | 670 | <div class="search-form lsx-search-form 2"> |
671 | 671 | <div class="input-group facetwp-search-wrap"> |
672 | 672 | <div class="field"> |
673 | - <input class="facetwp-search search-field form-control" type="text" placeholder="<?php echo esc_attr( $placeholder ); ?>" autocomplete="off" value="<?php echo esc_attr( $value ); ?>"> |
|
673 | + <input class="facetwp-search search-field form-control" type="text" placeholder="<?php echo esc_attr($placeholder); ?>" autocomplete="off" value="<?php echo esc_attr($value); ?>"> |
|
674 | 674 | </div> |
675 | 675 | |
676 | 676 | <div class="field submit-button"> |
677 | - <button class="search-submit btn facetwp-btn" type="submit"><?php esc_html_e( 'Search', 'lsx-search' ); ?></button> |
|
677 | + <button class="search-submit btn facetwp-btn" type="submit"><?php esc_html_e('Search', 'lsx-search'); ?></button> |
|
678 | 678 | </div> |
679 | 679 | </div> |
680 | 680 | </div> |
@@ -688,23 +688,23 @@ discard block |
||
688 | 688 | /** |
689 | 689 | * Change the primary and secondary column classes. |
690 | 690 | */ |
691 | - public function lsx_layout_selector( $return_class, $class, $layout, $size ) { |
|
692 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) { |
|
691 | + public function lsx_layout_selector($return_class, $class, $layout, $size) { |
|
692 | + if (!empty($this->options['display'][$this->search_prefix.'_layout'])) { |
|
693 | 693 | |
694 | - if ( '2cl' === $layout || '2cr' === $layout ) { |
|
694 | + if ('2cl' === $layout || '2cr' === $layout) { |
|
695 | 695 | $main_class = 'col-sm-8 col-md-9'; |
696 | 696 | $sidebar_class = 'col-sm-4 col-md-3'; |
697 | 697 | |
698 | - if ( '2cl' === $layout ) { |
|
698 | + if ('2cl' === $layout) { |
|
699 | 699 | $main_class .= ' col-sm-pull-4 col-md-pull-3'; |
700 | 700 | $sidebar_class .= ' col-sm-push-8 col-md-push-9'; |
701 | 701 | } |
702 | 702 | |
703 | - if ( 'main' === $class ) { |
|
703 | + if ('main' === $class) { |
|
704 | 704 | return $main_class; |
705 | 705 | } |
706 | 706 | |
707 | - if ( 'sidebar' === $class ) { |
|
707 | + if ('sidebar' === $class) { |
|
708 | 708 | return $sidebar_class; |
709 | 709 | } |
710 | 710 | } |
@@ -719,14 +719,14 @@ discard block |
||
719 | 719 | * @return void |
720 | 720 | */ |
721 | 721 | public function display_alphabet_facet() { |
722 | - if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
723 | - $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
722 | + if (isset($this->options['display'][$this->search_prefix.'_az_pagination'])) { |
|
723 | + $az_pagination = $this->options['display'][$this->search_prefix.'_az_pagination']; |
|
724 | 724 | } else { |
725 | 725 | $az_pagination = false; |
726 | 726 | } |
727 | - $az_pagination = apply_filters( 'lsx_search_top_az_pagination', $az_pagination ); |
|
728 | - if ( false !== $az_pagination && '' !== $az_pagination ) { |
|
729 | - echo do_shortcode( '[facetwp facet="' . $az_pagination . '"]' ); |
|
727 | + $az_pagination = apply_filters('lsx_search_top_az_pagination', $az_pagination); |
|
728 | + if (false !== $az_pagination && '' !== $az_pagination) { |
|
729 | + echo do_shortcode('[facetwp facet="'.$az_pagination.'"]'); |
|
730 | 730 | } |
731 | 731 | } |
732 | 732 | |
@@ -734,43 +734,43 @@ discard block |
||
734 | 734 | * Outputs top. |
735 | 735 | */ |
736 | 736 | public function facet_top_bar() { |
737 | - if ( true === apply_filters( 'lsx_search_hide_top_bar', false ) ) { |
|
737 | + if (true === apply_filters('lsx_search_hide_top_bar', false)) { |
|
738 | 738 | return; |
739 | 739 | } |
740 | 740 | $show_pagination = true; |
741 | 741 | $pagination_visible = false; |
742 | - $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
743 | - $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_all_sorting' ] ); |
|
744 | - |
|
745 | - $show_pagination = apply_filters( 'lsx_search_top_show_pagination', $show_pagination ); |
|
746 | - $pagination_visible = apply_filters( 'lsx_search_top_pagination_visible', $pagination_visible ); |
|
747 | - $show_per_page_combo = apply_filters( 'lsx_search_top_show_per_page_combo', $show_per_page_combo ); |
|
748 | - $show_sort_combo = apply_filters( 'lsx_search_top_show_sort_combo', $show_sort_combo ); |
|
749 | - $facet_row_classes = apply_filters( 'lsx_search_top_facetwp_row_classes', '' ); |
|
742 | + $show_per_page_combo = empty($this->options['display'][$this->search_prefix.'_disable_per_page']); |
|
743 | + $show_sort_combo = empty($this->options['display'][$this->search_prefix.'_disable_all_sorting']); |
|
744 | + |
|
745 | + $show_pagination = apply_filters('lsx_search_top_show_pagination', $show_pagination); |
|
746 | + $pagination_visible = apply_filters('lsx_search_top_pagination_visible', $pagination_visible); |
|
747 | + $show_per_page_combo = apply_filters('lsx_search_top_show_per_page_combo', $show_per_page_combo); |
|
748 | + $show_sort_combo = apply_filters('lsx_search_top_show_sort_combo', $show_sort_combo); |
|
749 | + $facet_row_classes = apply_filters('lsx_search_top_facetwp_row_classes', ''); |
|
750 | 750 | ?> |
751 | 751 | <div id="facetwp-top"> |
752 | - <?php if ( $show_sort_combo || ( $show_pagination && $show_per_page_combo ) ) { ?> |
|
753 | - <div class="row facetwp-top-row-1 hidden-xs <?php echo esc_attr( $facet_row_classes ); ?>"> |
|
752 | + <?php if ($show_sort_combo || ($show_pagination && $show_per_page_combo)) { ?> |
|
753 | + <div class="row facetwp-top-row-1 hidden-xs <?php echo esc_attr($facet_row_classes); ?>"> |
|
754 | 754 | <div class="col-xs-12"> |
755 | 755 | |
756 | - <?php if ( ! empty( $this->options['display'][ $this->search_prefix . '_display_result_count' ] ) && false === apply_filters( 'lsx_search_hide_result_count', false ) ) { ?> |
|
756 | + <?php if (!empty($this->options['display'][$this->search_prefix.'_display_result_count']) && false === apply_filters('lsx_search_hide_result_count', false)) { ?> |
|
757 | 757 | <div class="row"> |
758 | 758 | <div class="col-md-12 facetwp-item facetwp-results"> |
759 | - <h3 class="lsx-search-title lsx-search-title-results"><?php esc_html_e( 'Results', 'lsx-search' ); ?> <?php echo '(' . do_shortcode( '[facetwp counts="true"]' ) . ')'; ?> |
|
760 | - <?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' ] ) { ?> |
|
761 | - <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> |
|
759 | + <h3 class="lsx-search-title lsx-search-title-results"><?php esc_html_e('Results', 'lsx-search'); ?> <?php echo '('.do_shortcode('[facetwp counts="true"]').')'; ?> |
|
760 | + <?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']) { ?> |
|
761 | + <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> |
|
762 | 762 | <?php } ?> |
763 | 763 | </h3> |
764 | 764 | </div> |
765 | 765 | </div> |
766 | 766 | <?php } ?> |
767 | 767 | |
768 | - <?php do_action( 'lsx_search_facetwp_top_row' ); ?> |
|
768 | + <?php do_action('lsx_search_facetwp_top_row'); ?> |
|
769 | 769 | |
770 | 770 | <?php $this->display_alphabet_facet(); ?> |
771 | 771 | |
772 | - <?php if ( $show_sort_combo ) { ?> |
|
773 | - <?php echo do_shortcode( '[facetwp sort="true"]' ); ?> |
|
772 | + <?php if ($show_sort_combo) { ?> |
|
773 | + <?php echo do_shortcode('[facetwp sort="true"]'); ?> |
|
774 | 774 | <?php } ?> |
775 | 775 | |
776 | 776 | </div> |
@@ -784,30 +784,30 @@ discard block |
||
784 | 784 | * Outputs bottom. |
785 | 785 | */ |
786 | 786 | public function facet_bottom_bar() { |
787 | - if ( true === apply_filters( 'lsx_search_hide_bottom_bar', false ) ) { |
|
787 | + if (true === apply_filters('lsx_search_hide_bottom_bar', false)) { |
|
788 | 788 | return; |
789 | 789 | } |
790 | 790 | $show_pagination = true; |
791 | 791 | $pagination_visible = false; |
792 | - if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) { |
|
793 | - $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ]; |
|
792 | + if (isset($this->options['display'][$this->search_prefix.'_az_pagination'])) { |
|
793 | + $az_pagination = $this->options['display'][$this->search_prefix.'_az_pagination']; |
|
794 | 794 | } else { |
795 | 795 | $az_pagination = false; |
796 | 796 | } |
797 | 797 | |
798 | - $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] ); |
|
799 | - $show_sort_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_all_sorting' ] ); |
|
798 | + $show_per_page_combo = empty($this->options['display'][$this->search_prefix.'_disable_per_page']); |
|
799 | + $show_sort_combo = empty($this->options['display'][$this->search_prefix.'_disable_all_sorting']); |
|
800 | 800 | |
801 | - $show_pagination = apply_filters( 'lsx_search_bottom_show_pagination', $show_pagination ); |
|
802 | - $pagination_visible = apply_filters( 'lsx_search_bottom_pagination_visible', $pagination_visible ); |
|
803 | - $show_per_page_combo = apply_filters( 'lsx_search_bottom_show_per_page_combo', $show_per_page_combo ); |
|
804 | - $show_sort_combo = apply_filters( 'lsx_search_bottom_show_sort_combo', $show_sort_combo ); |
|
801 | + $show_pagination = apply_filters('lsx_search_bottom_show_pagination', $show_pagination); |
|
802 | + $pagination_visible = apply_filters('lsx_search_bottom_pagination_visible', $pagination_visible); |
|
803 | + $show_per_page_combo = apply_filters('lsx_search_bottom_show_per_page_combo', $show_per_page_combo); |
|
804 | + $show_sort_combo = apply_filters('lsx_search_bottom_show_sort_combo', $show_sort_combo); |
|
805 | 805 | |
806 | - if ( $show_pagination || ! empty( $az_pagination ) ) { ?> |
|
806 | + if ($show_pagination || !empty($az_pagination)) { ?> |
|
807 | 807 | <div id="facetwp-bottom"> |
808 | 808 | <div class="row facetwp-bottom-row-1"> |
809 | 809 | <div class="col-xs-12"> |
810 | - <?php do_action( 'lsx_search_facetwp_bottom_row' ); ?> |
|
810 | + <?php do_action('lsx_search_facetwp_bottom_row'); ?> |
|
811 | 811 | |
812 | 812 | <?php //if ( $show_sort_combo ) { ?> |
813 | 813 | <?php //echo do_shortcode( '[facetwp sort="true"]' ); ?> |
@@ -818,16 +818,16 @@ discard block |
||
818 | 818 | <?php //} ?> |
819 | 819 | |
820 | 820 | <?php |
821 | - if ( $show_pagination ) { |
|
822 | - $output_pagination = do_shortcode( '[facetwp pager="true"]' ); |
|
823 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
824 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
825 | - if ( isset( $this->facet_data[ $facet ] ) && in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
826 | - $output_pagination = do_shortcode( '[facetwp facet="pager_"]' ); |
|
821 | + if ($show_pagination) { |
|
822 | + $output_pagination = do_shortcode('[facetwp pager="true"]'); |
|
823 | + if (!empty($this->options['display'][$this->search_prefix.'_facets']) && is_array($this->options['display'][$this->search_prefix.'_facets'])) { |
|
824 | + foreach ($this->options['display'][$this->search_prefix.'_facets'] as $facet => $facet_useless) { |
|
825 | + if (isset($this->facet_data[$facet]) && in_array($this->facet_data[$facet]['type'], array('pager'))) { |
|
826 | + $output_pagination = do_shortcode('[facetwp facet="pager_"]'); |
|
827 | 827 | } |
828 | 828 | } |
829 | 829 | } |
830 | - echo wp_kses_post( $output_pagination ); |
|
830 | + echo wp_kses_post($output_pagination); |
|
831 | 831 | ?> |
832 | 832 | <?php } ?> |
833 | 833 | </div> |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | /** |
862 | 862 | * Disables default sidebar. |
863 | 863 | */ |
864 | - public function lsx_sidebar_enable( $sidebar_enabled ) { |
|
864 | + public function lsx_sidebar_enable($sidebar_enabled) { |
|
865 | 865 | $sidebar_enabled = false; |
866 | 866 | return $sidebar_enabled; |
867 | 867 | } |
@@ -871,19 +871,19 @@ discard block |
||
871 | 871 | */ |
872 | 872 | public function search_sidebar() { |
873 | 873 | |
874 | - $this->options = apply_filters( 'lsx_search_sidebar_options', $this->options ); |
|
874 | + $this->options = apply_filters('lsx_search_sidebar_options', $this->options); |
|
875 | 875 | ?> |
876 | - <?php do_action( 'lsx_search_sidebar_before' ); ?> |
|
876 | + <?php do_action('lsx_search_sidebar_before'); ?> |
|
877 | 877 | |
878 | - <div id="secondary" class="facetwp-sidebar widget-area <?php echo esc_attr( lsx_sidebar_class() ); ?>" role="complementary"> |
|
878 | + <div id="secondary" class="facetwp-sidebar widget-area <?php echo esc_attr(lsx_sidebar_class()); ?>" role="complementary"> |
|
879 | 879 | |
880 | - <?php do_action( 'lsx_search_sidebar_top' ); ?> |
|
880 | + <?php do_action('lsx_search_sidebar_top'); ?> |
|
881 | 881 | |
882 | - <?php if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { ?> |
|
882 | + <?php if (!empty($this->options['display'][$this->search_prefix.'_facets']) && is_array($this->options['display'][$this->search_prefix.'_facets'])) { ?> |
|
883 | 883 | <div class="row facetwp-row lsx-search-filer-area"> |
884 | - <h3 class="facetwp-filter-title"><?php echo esc_html_e( 'Refine by', 'lsx-search' ); ?></h3> |
|
884 | + <h3 class="facetwp-filter-title"><?php echo esc_html_e('Refine by', 'lsx-search'); ?></h3> |
|
885 | 885 | <div class="col-xs-12 facetwp-item facetwp-filters-button hidden-sm hidden-md hidden-lg"> |
886 | - <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> |
|
886 | + <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> |
|
887 | 887 | </div> |
888 | 888 | |
889 | 889 | <div class="ssm-overlay ssm-toggle-nav" rel="lsx-search-filters"></div> |
@@ -891,16 +891,16 @@ discard block |
||
891 | 891 | <div class="col-xs-12 facetwp-item-wrap facetwp-filters-wrap" id="lsx-search-filters"> |
892 | 892 | <div class="row hidden-sm hidden-md hidden-lg ssm-row-margin-bottom"> |
893 | 893 | <div class="col-xs-12 facetwp-item facetwp-filters-button"> |
894 | - <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> |
|
894 | + <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> |
|
895 | 895 | </div> |
896 | 896 | </div> |
897 | 897 | |
898 | 898 | <div class="row"> |
899 | 899 | <?php |
900 | 900 | // Slider. |
901 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
902 | - if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'alpha', 'search', 'pager' ) ) ) { |
|
903 | - $this->display_facet_default( $facet ); |
|
901 | + foreach ($this->options['display'][$this->search_prefix.'_facets'] as $facet => $facet_useless) { |
|
902 | + if (isset($this->facet_data[$facet]) && !in_array($this->facet_data[$facet]['type'], array('alpha', 'search', 'pager'))) { |
|
903 | + $this->display_facet_default($facet); |
|
904 | 904 | } |
905 | 905 | } |
906 | 906 | ?> |
@@ -908,17 +908,17 @@ discard block |
||
908 | 908 | |
909 | 909 | <div class="row hidden-sm hidden-md hidden-lg ssm-row-margin-top"> |
910 | 910 | <div class="col-xs-12 facetwp-item facetwp-filters-button"> |
911 | - <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> |
|
911 | + <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> |
|
912 | 912 | </div> |
913 | 913 | </div> |
914 | 914 | </div> |
915 | 915 | </div> |
916 | 916 | <?php } ?> |
917 | 917 | |
918 | - <?php do_action( 'lsx_search_sidebar_bottom' ); ?> |
|
918 | + <?php do_action('lsx_search_sidebar_bottom'); ?> |
|
919 | 919 | </div> |
920 | 920 | |
921 | - <?php do_action( 'lsx_search_sidebar_after' ); ?> |
|
921 | + <?php do_action('lsx_search_sidebar_after'); ?> |
|
922 | 922 | <?php |
923 | 923 | } |
924 | 924 | |
@@ -931,9 +931,9 @@ discard block |
||
931 | 931 | |
932 | 932 | $pager_facet_off = false; |
933 | 933 | |
934 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) { |
|
935 | - foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) { |
|
936 | - if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) { |
|
934 | + if (!empty($this->options['display'][$this->search_prefix.'_facets']) && is_array($this->options['display'][$this->search_prefix.'_facets'])) { |
|
935 | + foreach ($this->options['display'][$this->search_prefix.'_facets'] as $facet => $facet_useless) { |
|
936 | + if (isset($this->facet_data[$facet]) && !in_array($this->facet_data[$facet]['type'], array('pager'))) { |
|
937 | 937 | $pager_facet_off = true; |
938 | 938 | } |
939 | 939 | } |
@@ -947,9 +947,9 @@ discard block |
||
947 | 947 | */ |
948 | 948 | public function wc_archive_header() { |
949 | 949 | $default_size = 'sm'; |
950 | - $size = apply_filters( 'lsx_bootstrap_column_size', $default_size ); |
|
950 | + $size = apply_filters('lsx_bootstrap_column_size', $default_size); |
|
951 | 951 | ?> |
952 | - <div class="archive-header-wrapper banner-woocommerce col-<?php echo esc_attr( $size ); ?>-12"> |
|
952 | + <div class="archive-header-wrapper banner-woocommerce col-<?php echo esc_attr($size); ?>-12"> |
|
953 | 953 | <?php lsx_global_header_inner_bottom(); ?> |
954 | 954 | <header class="archive-header"> |
955 | 955 | <h1 class="archive-title"><?php woocommerce_page_title(); ?></h1> |
@@ -967,11 +967,11 @@ discard block |
||
967 | 967 | <form class="search-form lsx-search-form" action="/" method="get"> |
968 | 968 | <div class="input-group"> |
969 | 969 | <div class="field"> |
970 | - <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() ?>"> |
|
970 | + <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() ?>"> |
|
971 | 971 | </div> |
972 | 972 | |
973 | 973 | <div class="field submit-button"> |
974 | - <button class="search-submit btn" type="submit"><?php esc_html_e( 'Search', 'lsx-search' ); ?></button> |
|
974 | + <button class="search-submit btn" type="submit"><?php esc_html_e('Search', 'lsx-search'); ?></button> |
|
975 | 975 | </div> |
976 | 976 | </div> |
977 | 977 | </form> |
@@ -982,26 +982,26 @@ discard block |
||
982 | 982 | /** |
983 | 983 | * Display facet default. |
984 | 984 | */ |
985 | - public function display_facet_default( $facet ) { |
|
985 | + public function display_facet_default($facet) { |
|
986 | 986 | |
987 | - $show_collapse = ! isset( $this->options['display']['enable_collapse'] ) || 'on' !== $this->options['display']['enable_collapse']; |
|
987 | + $show_collapse = !isset($this->options['display']['enable_collapse']) || 'on' !== $this->options['display']['enable_collapse']; |
|
988 | 988 | $col_class = ''; |
989 | 989 | |
990 | - if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?> |
|
991 | - <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
|
990 | + if ('search' === $this->facet_data[$facet]['type']) : ?> |
|
991 | + <?php echo do_shortcode('[facetwp facet="'.$facet.'"]'); ?> |
|
992 | 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 ); ?>"> |
|
994 | - <?php if ( ! $show_collapse ) { ?> |
|
993 | + <div class="col-xs-12 facetwp-item parent-facetwp-facet-<?php echo esc_html($facet); ?> <?php echo esc_attr($col_class); ?>"> |
|
994 | + <?php if (!$show_collapse) { ?> |
|
995 | 995 | <div class="facetwp-collapsed"> |
996 | - <h3 class="lsx-search-title"><?php echo wp_kses_post( $this->facet_data[ $facet ]['label'] ); ?></h3> |
|
997 | - <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> |
|
996 | + <h3 class="lsx-search-title"><?php echo wp_kses_post($this->facet_data[$facet]['label']); ?></h3> |
|
997 | + <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> |
|
998 | 998 | </div> |
999 | - <div id="collapse-<?php echo esc_html( $facet ); ?>" class="collapse"> |
|
1000 | - <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
|
999 | + <div id="collapse-<?php echo esc_html($facet); ?>" class="collapse"> |
|
1000 | + <?php echo do_shortcode('[facetwp facet="'.$facet.'"]'); ?> |
|
1001 | 1001 | </div> |
1002 | 1002 | <?php } else { ?> |
1003 | - <h3 class="lsx-search-title"><?php echo wp_kses_post( $this->facet_data[ $facet ]['label'] ); ?></h3> |
|
1004 | - <?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?> |
|
1003 | + <h3 class="lsx-search-title"><?php echo wp_kses_post($this->facet_data[$facet]['label']); ?></h3> |
|
1004 | + <?php echo do_shortcode('[facetwp facet="'.$facet.'"]'); ?> |
|
1005 | 1005 | <?php } ?> |
1006 | 1006 | </div> |
1007 | 1007 | <?php |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | /** |
1012 | 1012 | * Changes slot column class. |
1013 | 1013 | */ |
1014 | - public function change_slot_column_class( $class ) { |
|
1015 | - if ( is_post_type_archive( 'video' ) || is_tax( 'video-category' ) ) { |
|
1014 | + public function change_slot_column_class($class) { |
|
1015 | + if (is_post_type_archive('video') || is_tax('video-category')) { |
|
1016 | 1016 | $column_class = 'col-xs-12 col-sm-4'; |
1017 | 1017 | } |
1018 | 1018 | |
@@ -1023,15 +1023,15 @@ discard block |
||
1023 | 1023 | * Add post type label to the title. |
1024 | 1024 | */ |
1025 | 1025 | public function add_label_to_title() { |
1026 | - if ( is_search() ) { |
|
1027 | - if ( ! empty( $this->options['display']['engine_search_enable_pt_label'] ) ) { |
|
1026 | + if (is_search()) { |
|
1027 | + if (!empty($this->options['display']['engine_search_enable_pt_label'])) { |
|
1028 | 1028 | $post_type = get_post_type(); |
1029 | - $post_type = str_replace( '_', ' ', $post_type ); |
|
1030 | - $post_type = str_replace( '-', ' ', $post_type ); |
|
1031 | - if ( 'tribe events' === $post_type ) { |
|
1029 | + $post_type = str_replace('_', ' ', $post_type); |
|
1030 | + $post_type = str_replace('-', ' ', $post_type); |
|
1031 | + if ('tribe events' === $post_type) { |
|
1032 | 1032 | $post_type = 'Events'; |
1033 | 1033 | } |
1034 | - echo wp_kses_post( ' <span class="label label-default lsx-label-post-type">' . $post_type . '</span>' ); |
|
1034 | + echo wp_kses_post(' <span class="label label-default lsx-label-post-type">'.$post_type.'</span>'); |
|
1035 | 1035 | } |
1036 | 1036 | } |
1037 | 1037 | } |
@@ -1039,22 +1039,22 @@ discard block |
||
1039 | 1039 | /** |
1040 | 1040 | * Changes the sort options. |
1041 | 1041 | */ |
1042 | - public function facetwp_sort_options( $options, $params ) { |
|
1042 | + public function facetwp_sort_options($options, $params) { |
|
1043 | 1043 | $this->set_vars(); |
1044 | 1044 | |
1045 | - if ( true === $this->search_enabled ) { |
|
1046 | - if ( 'default' !== $params['template_name'] && 'wp' !== $params['template_name'] ) { |
|
1045 | + if (true === $this->search_enabled) { |
|
1046 | + if ('default' !== $params['template_name'] && 'wp' !== $params['template_name']) { |
|
1047 | 1047 | return $options; |
1048 | 1048 | } |
1049 | 1049 | |
1050 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_date_sorting' ] ) ) { |
|
1051 | - unset( $options['date_desc'] ); |
|
1052 | - unset( $options['date_asc'] ); |
|
1050 | + if (!empty($this->options['display'][$this->search_prefix.'_disable_date_sorting'])) { |
|
1051 | + unset($options['date_desc']); |
|
1052 | + unset($options['date_asc']); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | - if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_az_sorting' ] ) ) { |
|
1056 | - unset( $options['title_desc'] ); |
|
1057 | - unset( $options['title_asc'] ); |
|
1055 | + if (!empty($this->options['display'][$this->search_prefix.'_disable_az_sorting'])) { |
|
1056 | + unset($options['title_desc']); |
|
1057 | + unset($options['title_asc']); |
|
1058 | 1058 | } |
1059 | 1059 | } |
1060 | 1060 | |
@@ -1067,9 +1067,9 @@ discard block |
||
1067 | 1067 | * |
1068 | 1068 | * @return mixed |
1069 | 1069 | */ |
1070 | - public function kses_allowed_html( $allowedtags, $context ) { |
|
1070 | + public function kses_allowed_html($allowedtags, $context) { |
|
1071 | 1071 | $allowedtags['a']['data-value'] = true; |
1072 | - $allowedtags['a']['data-selection'] = true; |
|
1072 | + $allowedtags['a']['data-selection'] = true; |
|
1073 | 1073 | $allowedtags['button']['data-toggle'] = true; |
1074 | 1074 | return $allowedtags; |
1075 | 1075 | } |
@@ -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> |
@@ -6,142 +6,142 @@ |
||
6 | 6 | */ |
7 | 7 | class LSX_Search_FacetWP { |
8 | 8 | |
9 | - /** |
|
10 | - * @var object \lsx\search\classes\facetwp\Hierarchy() |
|
11 | - */ |
|
12 | - public $hierarchy; |
|
13 | - |
|
14 | - /** |
|
15 | - * @var object \lsx\search\classes\facetwp\Post_Connections() |
|
16 | - */ |
|
17 | - public $post_connections; |
|
18 | - |
|
19 | - /** |
|
20 | - * Class Constructor. |
|
21 | - */ |
|
22 | - public function __construct() { |
|
23 | - |
|
24 | - require_once LSX_SEARCH_PATH . '/classes/facetwp/class-hierarchy.php'; |
|
25 | - $this->hierarchy = lsx\search\classes\facetwp\Hierarchy::get_instance(); |
|
26 | - |
|
27 | - require_once LSX_SEARCH_PATH . '/classes/facetwp/class-post-connections.php'; |
|
28 | - $this->post_connections = lsx\search\classes\facetwp\Post_Connections::get_instance(); |
|
29 | - |
|
30 | - add_filter( 'facetwp_pager_html', array( $this, 'facetwp_pager_html' ), 10, 2 ); |
|
31 | - add_filter( 'facetwp_result_count', array( $this, 'facetwp_result_count' ), 10, 2 ); |
|
32 | - add_filter( 'facetwp_facet_html', array( $this, 'facetwp_slide_html' ), 10, 2 ); |
|
33 | - add_filter( 'facetwp_load_css', array( $this, 'facetwp_load_css' ), 10, 1 ); |
|
34 | - add_filter( 'facetwp_index_row', array( $this, 'index_row' ), 10, 2 ); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Change FaceWP pagination HTML to be equal LSX pagination. |
|
39 | - */ |
|
40 | - public function facetwp_pager_html( $output, $params ) { |
|
41 | - $output = ''; |
|
42 | - $page = (int) $params['page']; |
|
43 | - $per_page = (int) $params['per_page']; |
|
44 | - $total_pages = (int) $params['total_pages']; |
|
45 | - |
|
46 | - if ( 1 < $total_pages ) { |
|
47 | - $output .= '<div class="lsx-pagination-wrapper facetwp-custom">'; |
|
48 | - $output .= '<div class="lsx-pagination">'; |
|
49 | - // $output .= '<span class="pages">Page '. $page .' of '. $total_pages .'</span>'; |
|
50 | - |
|
51 | - if ( 1 < $page ) { |
|
52 | - $output .= '<a class="prev page-numbers facetwp-page" rel="prev" data-page="' . ( $page - 1 ) . '">«</a>'; |
|
53 | - } |
|
54 | - |
|
55 | - $temp = false; |
|
56 | - |
|
57 | - for ( $i = 1; $i <= $total_pages; $i++ ) { |
|
58 | - if ( $i == $page ) { |
|
59 | - $output .= '<span class="page-numbers current">' . $i . '</span>'; |
|
60 | - } elseif ( ( $page - 2 ) < $i && ( $page + 2 ) > $i ) { |
|
61 | - $output .= '<a class="page-numbers facetwp-page" data-page="' . $i . '">' . $i . '</a>'; |
|
62 | - } elseif ( ( $page - 2 ) >= $i && $page > 2 ) { |
|
63 | - if ( ! $temp ) { |
|
64 | - $output .= '<span class="page-numbers dots">...</span>'; |
|
65 | - $temp = true; |
|
66 | - } |
|
67 | - } elseif ( ( $page + 2 ) <= $i && ( $page + 2 ) <= $total_pages ) { |
|
68 | - $output .= '<span class="page-numbers dots">...</span>'; |
|
69 | - break; |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - if ( $page < $total_pages ) { |
|
74 | - $output .= '<a class="next page-numbers facetwp-page" rel="next" data-page="' . ( $page + 1 ) . '">»</a>'; |
|
75 | - } |
|
76 | - |
|
77 | - $output .= '</div>'; |
|
78 | - $output .= '</div>'; |
|
79 | - } |
|
80 | - |
|
81 | - return $output; |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * Change FaceWP result count HTML. |
|
86 | - */ |
|
87 | - public function facetwp_result_count( $output, $params ) { |
|
88 | - $output = $params['total']; |
|
89 | - return $output; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Change FaceWP slider HTML. |
|
94 | - */ |
|
95 | - public function facetwp_slide_html( $html, $args ) { |
|
96 | - if ( 'slider' === $args['facet']['type'] ) { |
|
97 | - $html = str_replace( 'class="facetwp-slider-reset"', 'class="btn btn-md facetwp-slider-reset"', $html ); |
|
98 | - } |
|
99 | - |
|
100 | - return $html; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Change FaceWP slider HTML. |
|
105 | - */ |
|
106 | - public function facetwp_counts_html( $html, $args ) { |
|
107 | - if ( 'slider' === $args['facet']['type'] ) { |
|
108 | - $html = str_replace( 'class="facetwp-slider-reset"', 'class="btn btn-md facetwp-slider-reset"', $html ); |
|
109 | - } |
|
110 | - return $html; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Disable FacetWP styles. |
|
115 | - */ |
|
116 | - public function facetwp_load_css( $boolean ) { |
|
117 | - $boolean = false; |
|
118 | - return $boolean; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Get the price including the tax |
|
123 | - * @param $params |
|
124 | - * @param $class |
|
125 | - * |
|
126 | - * @return mixed |
|
127 | - */ |
|
128 | - public function index_row( $params, $class ) { |
|
129 | - // Custom woo fields |
|
130 | - if ( 0 === strpos( $params['facet_source'], 'woo' ) ) { |
|
131 | - $product = wc_get_product( $params['post_id'] ); |
|
132 | - |
|
133 | - // Price |
|
134 | - if ( in_array( $params['facet_source'], array( 'woo/price', 'woo/sale_price', 'woo/regular_price' ) ) ) { |
|
135 | - $price = $params['facet_value']; |
|
136 | - if ( $product->is_taxable() ) { |
|
137 | - $price = wc_get_price_including_tax( $product ); |
|
138 | - } |
|
139 | - $params['facet_value'] = $price; |
|
140 | - $params['facet_display_value'] = $price; |
|
141 | - |
|
142 | - } |
|
143 | - } |
|
144 | - return $params; |
|
145 | - } |
|
9 | + /** |
|
10 | + * @var object \lsx\search\classes\facetwp\Hierarchy() |
|
11 | + */ |
|
12 | + public $hierarchy; |
|
13 | + |
|
14 | + /** |
|
15 | + * @var object \lsx\search\classes\facetwp\Post_Connections() |
|
16 | + */ |
|
17 | + public $post_connections; |
|
18 | + |
|
19 | + /** |
|
20 | + * Class Constructor. |
|
21 | + */ |
|
22 | + public function __construct() { |
|
23 | + |
|
24 | + require_once LSX_SEARCH_PATH . '/classes/facetwp/class-hierarchy.php'; |
|
25 | + $this->hierarchy = lsx\search\classes\facetwp\Hierarchy::get_instance(); |
|
26 | + |
|
27 | + require_once LSX_SEARCH_PATH . '/classes/facetwp/class-post-connections.php'; |
|
28 | + $this->post_connections = lsx\search\classes\facetwp\Post_Connections::get_instance(); |
|
29 | + |
|
30 | + add_filter( 'facetwp_pager_html', array( $this, 'facetwp_pager_html' ), 10, 2 ); |
|
31 | + add_filter( 'facetwp_result_count', array( $this, 'facetwp_result_count' ), 10, 2 ); |
|
32 | + add_filter( 'facetwp_facet_html', array( $this, 'facetwp_slide_html' ), 10, 2 ); |
|
33 | + add_filter( 'facetwp_load_css', array( $this, 'facetwp_load_css' ), 10, 1 ); |
|
34 | + add_filter( 'facetwp_index_row', array( $this, 'index_row' ), 10, 2 ); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * Change FaceWP pagination HTML to be equal LSX pagination. |
|
39 | + */ |
|
40 | + public function facetwp_pager_html( $output, $params ) { |
|
41 | + $output = ''; |
|
42 | + $page = (int) $params['page']; |
|
43 | + $per_page = (int) $params['per_page']; |
|
44 | + $total_pages = (int) $params['total_pages']; |
|
45 | + |
|
46 | + if ( 1 < $total_pages ) { |
|
47 | + $output .= '<div class="lsx-pagination-wrapper facetwp-custom">'; |
|
48 | + $output .= '<div class="lsx-pagination">'; |
|
49 | + // $output .= '<span class="pages">Page '. $page .' of '. $total_pages .'</span>'; |
|
50 | + |
|
51 | + if ( 1 < $page ) { |
|
52 | + $output .= '<a class="prev page-numbers facetwp-page" rel="prev" data-page="' . ( $page - 1 ) . '">«</a>'; |
|
53 | + } |
|
54 | + |
|
55 | + $temp = false; |
|
56 | + |
|
57 | + for ( $i = 1; $i <= $total_pages; $i++ ) { |
|
58 | + if ( $i == $page ) { |
|
59 | + $output .= '<span class="page-numbers current">' . $i . '</span>'; |
|
60 | + } elseif ( ( $page - 2 ) < $i && ( $page + 2 ) > $i ) { |
|
61 | + $output .= '<a class="page-numbers facetwp-page" data-page="' . $i . '">' . $i . '</a>'; |
|
62 | + } elseif ( ( $page - 2 ) >= $i && $page > 2 ) { |
|
63 | + if ( ! $temp ) { |
|
64 | + $output .= '<span class="page-numbers dots">...</span>'; |
|
65 | + $temp = true; |
|
66 | + } |
|
67 | + } elseif ( ( $page + 2 ) <= $i && ( $page + 2 ) <= $total_pages ) { |
|
68 | + $output .= '<span class="page-numbers dots">...</span>'; |
|
69 | + break; |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + if ( $page < $total_pages ) { |
|
74 | + $output .= '<a class="next page-numbers facetwp-page" rel="next" data-page="' . ( $page + 1 ) . '">»</a>'; |
|
75 | + } |
|
76 | + |
|
77 | + $output .= '</div>'; |
|
78 | + $output .= '</div>'; |
|
79 | + } |
|
80 | + |
|
81 | + return $output; |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * Change FaceWP result count HTML. |
|
86 | + */ |
|
87 | + public function facetwp_result_count( $output, $params ) { |
|
88 | + $output = $params['total']; |
|
89 | + return $output; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Change FaceWP slider HTML. |
|
94 | + */ |
|
95 | + public function facetwp_slide_html( $html, $args ) { |
|
96 | + if ( 'slider' === $args['facet']['type'] ) { |
|
97 | + $html = str_replace( 'class="facetwp-slider-reset"', 'class="btn btn-md facetwp-slider-reset"', $html ); |
|
98 | + } |
|
99 | + |
|
100 | + return $html; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Change FaceWP slider HTML. |
|
105 | + */ |
|
106 | + public function facetwp_counts_html( $html, $args ) { |
|
107 | + if ( 'slider' === $args['facet']['type'] ) { |
|
108 | + $html = str_replace( 'class="facetwp-slider-reset"', 'class="btn btn-md facetwp-slider-reset"', $html ); |
|
109 | + } |
|
110 | + return $html; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Disable FacetWP styles. |
|
115 | + */ |
|
116 | + public function facetwp_load_css( $boolean ) { |
|
117 | + $boolean = false; |
|
118 | + return $boolean; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Get the price including the tax |
|
123 | + * @param $params |
|
124 | + * @param $class |
|
125 | + * |
|
126 | + * @return mixed |
|
127 | + */ |
|
128 | + public function index_row( $params, $class ) { |
|
129 | + // Custom woo fields |
|
130 | + if ( 0 === strpos( $params['facet_source'], 'woo' ) ) { |
|
131 | + $product = wc_get_product( $params['post_id'] ); |
|
132 | + |
|
133 | + // Price |
|
134 | + if ( in_array( $params['facet_source'], array( 'woo/price', 'woo/sale_price', 'woo/regular_price' ) ) ) { |
|
135 | + $price = $params['facet_value']; |
|
136 | + if ( $product->is_taxable() ) { |
|
137 | + $price = wc_get_price_including_tax( $product ); |
|
138 | + } |
|
139 | + $params['facet_value'] = $price; |
|
140 | + $params['facet_display_value'] = $price; |
|
141 | + |
|
142 | + } |
|
143 | + } |
|
144 | + return $params; |
|
145 | + } |
|
146 | 146 | |
147 | 147 | } |
@@ -21,57 +21,57 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | 23 | |
24 | - require_once LSX_SEARCH_PATH . '/classes/facetwp/class-hierarchy.php'; |
|
24 | + require_once LSX_SEARCH_PATH.'/classes/facetwp/class-hierarchy.php'; |
|
25 | 25 | $this->hierarchy = lsx\search\classes\facetwp\Hierarchy::get_instance(); |
26 | 26 | |
27 | - require_once LSX_SEARCH_PATH . '/classes/facetwp/class-post-connections.php'; |
|
27 | + require_once LSX_SEARCH_PATH.'/classes/facetwp/class-post-connections.php'; |
|
28 | 28 | $this->post_connections = lsx\search\classes\facetwp\Post_Connections::get_instance(); |
29 | 29 | |
30 | - add_filter( 'facetwp_pager_html', array( $this, 'facetwp_pager_html' ), 10, 2 ); |
|
31 | - add_filter( 'facetwp_result_count', array( $this, 'facetwp_result_count' ), 10, 2 ); |
|
32 | - add_filter( 'facetwp_facet_html', array( $this, 'facetwp_slide_html' ), 10, 2 ); |
|
33 | - add_filter( 'facetwp_load_css', array( $this, 'facetwp_load_css' ), 10, 1 ); |
|
34 | - add_filter( 'facetwp_index_row', array( $this, 'index_row' ), 10, 2 ); |
|
30 | + add_filter('facetwp_pager_html', array($this, 'facetwp_pager_html'), 10, 2); |
|
31 | + add_filter('facetwp_result_count', array($this, 'facetwp_result_count'), 10, 2); |
|
32 | + add_filter('facetwp_facet_html', array($this, 'facetwp_slide_html'), 10, 2); |
|
33 | + add_filter('facetwp_load_css', array($this, 'facetwp_load_css'), 10, 1); |
|
34 | + add_filter('facetwp_index_row', array($this, 'index_row'), 10, 2); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Change FaceWP pagination HTML to be equal LSX pagination. |
39 | 39 | */ |
40 | - public function facetwp_pager_html( $output, $params ) { |
|
40 | + public function facetwp_pager_html($output, $params) { |
|
41 | 41 | $output = ''; |
42 | 42 | $page = (int) $params['page']; |
43 | 43 | $per_page = (int) $params['per_page']; |
44 | 44 | $total_pages = (int) $params['total_pages']; |
45 | 45 | |
46 | - if ( 1 < $total_pages ) { |
|
46 | + if (1 < $total_pages) { |
|
47 | 47 | $output .= '<div class="lsx-pagination-wrapper facetwp-custom">'; |
48 | 48 | $output .= '<div class="lsx-pagination">'; |
49 | 49 | // $output .= '<span class="pages">Page '. $page .' of '. $total_pages .'</span>'; |
50 | 50 | |
51 | - if ( 1 < $page ) { |
|
52 | - $output .= '<a class="prev page-numbers facetwp-page" rel="prev" data-page="' . ( $page - 1 ) . '">«</a>'; |
|
51 | + if (1 < $page) { |
|
52 | + $output .= '<a class="prev page-numbers facetwp-page" rel="prev" data-page="'.($page - 1).'">«</a>'; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $temp = false; |
56 | 56 | |
57 | - for ( $i = 1; $i <= $total_pages; $i++ ) { |
|
58 | - if ( $i == $page ) { |
|
59 | - $output .= '<span class="page-numbers current">' . $i . '</span>'; |
|
60 | - } elseif ( ( $page - 2 ) < $i && ( $page + 2 ) > $i ) { |
|
61 | - $output .= '<a class="page-numbers facetwp-page" data-page="' . $i . '">' . $i . '</a>'; |
|
62 | - } elseif ( ( $page - 2 ) >= $i && $page > 2 ) { |
|
63 | - if ( ! $temp ) { |
|
57 | + for ($i = 1; $i <= $total_pages; $i++) { |
|
58 | + if ($i == $page) { |
|
59 | + $output .= '<span class="page-numbers current">'.$i.'</span>'; |
|
60 | + } elseif (($page - 2) < $i && ($page + 2) > $i) { |
|
61 | + $output .= '<a class="page-numbers facetwp-page" data-page="'.$i.'">'.$i.'</a>'; |
|
62 | + } elseif (($page - 2) >= $i && $page > 2) { |
|
63 | + if (!$temp) { |
|
64 | 64 | $output .= '<span class="page-numbers dots">...</span>'; |
65 | 65 | $temp = true; |
66 | 66 | } |
67 | - } elseif ( ( $page + 2 ) <= $i && ( $page + 2 ) <= $total_pages ) { |
|
67 | + } elseif (($page + 2) <= $i && ($page + 2) <= $total_pages) { |
|
68 | 68 | $output .= '<span class="page-numbers dots">...</span>'; |
69 | 69 | break; |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | - if ( $page < $total_pages ) { |
|
74 | - $output .= '<a class="next page-numbers facetwp-page" rel="next" data-page="' . ( $page + 1 ) . '">»</a>'; |
|
73 | + if ($page < $total_pages) { |
|
74 | + $output .= '<a class="next page-numbers facetwp-page" rel="next" data-page="'.($page + 1).'">»</a>'; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $output .= '</div>'; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | /** |
85 | 85 | * Change FaceWP result count HTML. |
86 | 86 | */ |
87 | - public function facetwp_result_count( $output, $params ) { |
|
87 | + public function facetwp_result_count($output, $params) { |
|
88 | 88 | $output = $params['total']; |
89 | 89 | return $output; |
90 | 90 | } |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * Change FaceWP slider HTML. |
94 | 94 | */ |
95 | - public function facetwp_slide_html( $html, $args ) { |
|
96 | - if ( 'slider' === $args['facet']['type'] ) { |
|
97 | - $html = str_replace( 'class="facetwp-slider-reset"', 'class="btn btn-md facetwp-slider-reset"', $html ); |
|
95 | + public function facetwp_slide_html($html, $args) { |
|
96 | + if ('slider' === $args['facet']['type']) { |
|
97 | + $html = str_replace('class="facetwp-slider-reset"', 'class="btn btn-md facetwp-slider-reset"', $html); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | return $html; |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * Change FaceWP slider HTML. |
105 | 105 | */ |
106 | - public function facetwp_counts_html( $html, $args ) { |
|
107 | - if ( 'slider' === $args['facet']['type'] ) { |
|
108 | - $html = str_replace( 'class="facetwp-slider-reset"', 'class="btn btn-md facetwp-slider-reset"', $html ); |
|
106 | + public function facetwp_counts_html($html, $args) { |
|
107 | + if ('slider' === $args['facet']['type']) { |
|
108 | + $html = str_replace('class="facetwp-slider-reset"', 'class="btn btn-md facetwp-slider-reset"', $html); |
|
109 | 109 | } |
110 | 110 | return $html; |
111 | 111 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * Disable FacetWP styles. |
115 | 115 | */ |
116 | - public function facetwp_load_css( $boolean ) { |
|
116 | + public function facetwp_load_css($boolean) { |
|
117 | 117 | $boolean = false; |
118 | 118 | return $boolean; |
119 | 119 | } |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return mixed |
127 | 127 | */ |
128 | - public function index_row( $params, $class ) { |
|
128 | + public function index_row($params, $class) { |
|
129 | 129 | // Custom woo fields |
130 | - if ( 0 === strpos( $params['facet_source'], 'woo' ) ) { |
|
131 | - $product = wc_get_product( $params['post_id'] ); |
|
130 | + if (0 === strpos($params['facet_source'], 'woo')) { |
|
131 | + $product = wc_get_product($params['post_id']); |
|
132 | 132 | |
133 | 133 | // Price |
134 | - if ( in_array( $params['facet_source'], array( 'woo/price', 'woo/sale_price', 'woo/regular_price' ) ) ) { |
|
134 | + if (in_array($params['facet_source'], array('woo/price', 'woo/sale_price', 'woo/regular_price'))) { |
|
135 | 135 | $price = $params['facet_value']; |
136 | - if ( $product->is_taxable() ) { |
|
137 | - $price = wc_get_price_including_tax( $product ); |
|
136 | + if ($product->is_taxable()) { |
|
137 | + $price = wc_get_price_including_tax($product); |
|
138 | 138 | } |
139 | - $params['facet_value'] = $price; |
|
139 | + $params['facet_value'] = $price; |
|
140 | 140 | $params['facet_display_value'] = $price; |
141 | 141 | |
142 | 142 | } |