Passed
Push — dependabot/composer/phpcompati... ( 2dc932 )
by
unknown
05:12
created
classes/class-admin.php 1 patch
Indentation   +483 added lines, -483 removed lines patch added patch discarded remove patch
@@ -12,475 +12,475 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class Admin {
14 14
 
15
-	/**
16
-	 * Holds class instance
17
-	 *
18
-	 * @since 1.0.0
19
-	 *
20
-	 * @var      object \lsx\search\classes\Admin()
21
-	 */
22
-	protected static $instance = null;
23
-	/**
24
-	 * Holds the options for the search.
25
-	 *
26
-	 * @var array()
27
-	 */
28
-	public $options = false;
29
-
30
-	/**
31
-	 * Holds the facetwp data for use in the fields.
32
-	 *
33
-	 * @var array()
34
-	 */
35
-	public $facet_data = false;
36
-
37
-	/**
38
-	 * Holds the Alpha betical facetwp data for use in the fields.
39
-	 *
40
-	 * @var array()
41
-	 */
42
-	public $az_facets = array();
43
-
44
-	/**
45
-	 * Holds the settings page theme functions
46
-	 *
47
-	 * @var object \lsx\search\classes\admin\Settings_Theme();
48
-	 */
49
-	public $settings_theme;
50
-
51
-	/**
52
-	 * Construct method.
53
-	 */
54
-	public function __construct() {
55
-		$this->load_classes();
56
-		add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) );
57
-		add_action( 'lsx_search_settings_page', array( $this, 'configure_settings_search_engine_fields' ), 15, 1 );
58
-		add_action( 'lsx_search_settings_page', array( $this, 'configure_settings_search_archive_fields' ), 15, 1 );
59
-		add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
60
-
61
-		if ( is_admin() ) {
62
-			add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 );
63
-			add_filter( 'lsx_customizer_colour_selectors_button', array( $this, 'customizer_button_colours' ), 10, 2 );
64
-		}
65
-	}
66
-
67
-	/**
68
-	 * Return an instance of this class.
69
-	 *
70
-	 * @since 1.0.0
71
-	 *
72
-	 * @return    object \lsx\member_directory\search\Admin()    A single instance of this class.
73
-	 */
74
-	public static function get_instance() {
75
-		// If the single instance hasn't been set, set it now.
76
-		if ( null === self::$instance ) {
77
-			self::$instance = new self();
78
-		}
79
-		return self::$instance;
80
-	}
81
-
82
-	/**
83
-	 * Loads the variable classes and the static classes.
84
-	 */
85
-	private function load_classes() {
86
-		require_once LSX_SEARCH_PATH . 'classes/admin/class-settings-theme.php';
87
-		$this->settings_theme = admin\Settings_Theme::get_instance();
88
-	}
89
-
90
-	/**
91
-	 * Configure Business Directory custom fields for the Settings page.
92
-	 *
93
-	 * @return void
94
-	 */
95
-	public function register_settings_page() {
96
-		$args = array(
97
-			'id'           => 'lsx_search_settings',
98
-			'title'        => '<h1>' . esc_html__( 'LSX Search Settings', 'lsx-search' ) . ' <span class="version">' . LSX_SEARCH_VER . '</span></h1>',
99
-			'menu_title'   => esc_html__( 'LSX Search', 'search' ), // Falls back to 'title' (above).
100
-			'object_types' => array( 'options-page' ),
101
-			'option_key'   => 'lsx-search-settings', // The option key and admin menu page slug.
102
-			'parent_slug'  => 'options-general.php',
103
-			'capability'   => 'manage_options', // Cap required to view options-page.
104
-		);
105
-		$cmb  = new_cmb2_box( $args );
106
-		do_action( 'lsx_search_settings_page', $cmb );
107
-	}
108
-
109
-	/**
110
-	 * Sets post types with active search options.
111
-	 */
112
-	public function register_post_type_tabs( $post_types_plural ) {
113
-		$post_types_plural = array(
114
-			'project' => 'projects',
115
-			'service' => 'services',
116
-			'team' => 'team',
117
-			'testimonial' => 'testimonials',
118
-			'video' => 'videos',
119
-			'product' => 'products', // WooCommerce
120
-			'post' => 'posts',
121
-		);
122
-		return $post_types_plural;
123
-	}
124
-
125
-	/**
126
-	 * Gets the Tour Operator Post Types.
127
-	 *
128
-	 * @return array
129
-	 */
130
-	public function get_to_post_types() {
131
-		$to_types = array(
132
-			'accommodation',
133
-			'tour',
134
-			'destination',
135
-			'review',
136
-			'activity',
137
-			'special',
138
-			'vehicle',
139
-		);
140
-		return $to_types;
141
-	}
142
-
143
-	/**
144
-	 * Sets the FacetWP variables.
145
-	 *
146
-	 * @return  void
147
-	 */
148
-	public function set_facetwp_vars() {
149
-		if ( function_exists( '\FWP' ) ) {
150
-			$facet_data = \FWP()->helper->get_facets();
151
-		}
152
-		$this->facet_data = array();
153
-		$this->az_facets  = array(
154
-			'' => __( 'Do not show', 'lsx-search' ),
155
-		);
156
-		if ( ! empty( $facet_data ) && is_array( $facet_data ) ) {
157
-			foreach ( $facet_data as $facet ) {
158
-				if ( 'alpha' === $facet['type'] ) {
159
-					$this->az_facets[ $facet['name'] ] = $facet['label'] . '(' . $facet['name'] . ')';
160
-				} else {
161
-					$this->facet_data[ $facet['name'] ] = $facet['label'] . '(' . $facet['name'] . ')';
162
-				}
163
-			}
164
-		}
165
-	}
166
-
167
-	/**
168
-	 * Enqueue JS and CSS.
169
-	 */
170
-	public function assets( $hook ) {
171
-		wp_enqueue_script( 'lsx-search-admin', LSX_SEARCH_URL . 'assets/js/src/lsx-search-admin.js', array( 'jquery' ), LSX_SEARCH_VER, true );
172
-		wp_enqueue_style( 'lsx-search-admin', LSX_SEARCH_URL . 'assets/css/lsx-search-admin.css', array(), LSX_SEARCH_VER );
173
-	}
174
-
175
-	/**
176
-	 * Enable Business Directory Search settings only if LSX Search plugin is enabled.
177
-	 *
178
-	 * @return  void
179
-	 */
180
-	public function configure_settings_search_engine_fields( $cmb ) {
181
-		$global_args = array(
182
-			'title' => __( 'Global', 'lsx-search' ),
183
-			'desc'  => esc_html__( 'Control the filters which show on your WordPress search results page.', 'lsx-search' ),
184
-		);
185
-		$this->search_fields( $cmb, 'engine', $global_args );
186
-	}
187
-
188
-	/**
189
-	 * Enable Business Directory Search settings only if LSX Search plugin is enabled.
190
-	 *
191
-	 * @param object $cmb The CMB2() class.
192
-	 * @param string $position either top of bottom.
193
-	 * @return void
194
-	 */
195
-	public function configure_settings_search_archive_fields( $cmb ) {
196
-		$archives       = array();
197
-		$post_type_args = array(
198
-			'public' => true,
199
-		);
200
-		$post_types     = get_post_types( $post_type_args );
201
-		if ( ! empty( $post_types ) ) {
202
-			foreach ( $post_types as $post_type_key => $post_type_value ) {
203
-				switch ( $post_type_key ) {
204
-					case 'post':
205
-						$page_url      = home_url();
206
-						$page_title    = __( 'Home', 'lsx-search' );
207
-						$show_on_front = get_option( 'show_on_front' );
208
-						if ( 'page' === $show_on_front ) {
209
-							$page_for_posts = get_option( 'page_for_posts' );
210
-							if ( '' !== $page_for_posts ) {
211
-								$page_title   = get_the_title( $page_for_posts );
212
-								$page_url     = get_permalink( $page_for_posts );
213
-							}
214
-						}
215
-						$description = sprintf(
216
-							/* translators: %s: The subscription info */
217
-							__( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> page.', 'lsx-search' ),
218
-							$page_url,
219
-							$page_title
220
-						);
221
-						$archives[ $post_type_key ] = array(
222
-							'title' => __( 'Blog', 'lsx-search' ),
223
-							'desc'  => $description,
224
-						);
225
-						break;
226
-
227
-					case 'product':
228
-						$page_url = home_url();
229
-						$page_title    = __( 'Shop', 'lsx-search' );
230
-						if ( function_exists( 'wc_get_page_id' ) ) {
231
-							$shop_page  = wc_get_page_id( 'shop' );
232
-							$page_url   = get_permalink( $shop_page );
233
-							$page_title = get_the_title( $shop_page );
234
-						}
235
-						$description = sprintf(
236
-							/* translators: %s: The subscription info */
237
-							__( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> page.', 'lsx-search' ),
238
-							$page_url,
239
-							$page_title
240
-						);
241
-						$archives[ $post_type_key ] = array(
242
-							'title' => __( 'Shop', 'lsx-search' ),
243
-							'desc'  => $description,
244
-						);
245
-						break;
246
-
247
-					default:
248
-						if ( ! in_array( $post_type_key, \lsx\search\includes\get_restricted_post_types() ) ) {
249
-							$temp_post_type = get_post_type_object( $post_type_key );
250
-							if ( ! is_wp_error( $temp_post_type ) ) {
251
-								$page_url    = get_post_type_archive_link( $temp_post_type->name );
252
-								$description = sprintf(
253
-									/* translators: %s: The subscription info */
254
-									__( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ),
255
-									$page_url,
256
-									$temp_post_type->label
257
-								);
258
-
259
-								$archives[ $post_type_key ] = array(
260
-									'title' => $temp_post_type->label,
261
-									'desc'  => $description,
262
-								);
263
-							}
264
-						}
265
-						break;
266
-				}
267
-			}
268
-		}
269
-		if ( ! empty( $archives ) ) {
270
-			foreach ( $archives as $archive_key => $archive_args ) {
271
-				$this->search_fields( $cmb, $archive_key, $archive_args );
272
-			}
273
-		}
274
-	}
275
-
276
-	/**
277
-	 * Enable Business Directory Search settings only if LSX Search plugin is enabled.
278
-	 *
279
-	 * @param object $cmb The CMB2() class.
280
-	 * @param string $section either engine,archive or single.
281
-	 * @return void
282
-	 */
283
-	public function search_fields( $cmb, $section, $args ) {
284
-		$this->set_facetwp_vars();
285
-		$cmb->add_field(
286
-			array(
287
-				'id'          => 'settings_' . $section . '_search',
288
-				'type'        => 'title',
289
-				'name'        => $args['title'],
290
-				'default'     => $args['title'],
291
-				'description' => $args['desc'],
292
-			)
293
-		);
294
-		do_action( 'lsx_search_settings_section', $cmb, 'top' );
295
-		$cmb->add_field(
296
-			array(
297
-				'name'        => esc_html__( 'Enable Search Filters', 'lsx-search' ),
298
-				'id'          => $section . '_search_enable',
299
-				'description' => esc_html__( 'Display FacetWP filters on your search results page.', 'lsx-search' ),
300
-				'type'        => 'checkbox',
301
-			)
302
-		);
303
-
304
-		$cmb->add_field(
305
-			array(
306
-				'name'    => esc_html__( 'Page Layout', 'lsx-search' ),
307
-				'id'      => $section . '_search_layout',
308
-				'type'    => 'select',
309
-				'options' => array(
310
-					''    => esc_html__( 'Follow the theme layout', 'lsx-search' ),
311
-					'2cr' => esc_html__( 'Sidebar on left', 'lsx-search' ),
312
-					'2cl' => esc_html__( 'Sidebar on right', 'lsx-search' ),
313
-				),
314
-				'default' => '',
315
-			)
316
-		);
317
-
318
-		if ( 'product' === $section ) {
319
-			$cmb->add_field(
320
-				array(
321
-					'name'             => esc_html__( 'Results Layout', 'lsx-search' ),
322
-					'id'               => $section . '_search_grid_list',
323
-					'type'             => 'select',
324
-					'show_option_none' => false,
325
-					'description'      => __( 'Set a default layout for the search results.', 'lsx-search' ),
326
-					'options'          => array(
327
-						'grid' => esc_html__( 'Grid', 'lsx-search' ),
328
-						'list' => esc_html__( 'List', 'lsx-search' ),
329
-					),
330
-					'default' => 'grid',
331
-				)
332
-			);
333
-			$cmb->add_field(
334
-				array(
335
-					'name'        => esc_html__( 'Layout Switcher', 'lsx-search' ),
336
-					'id'          => $section . '_search_layout_switcher_enable',
337
-					'type'        => 'checkbox',
338
-					'description' => __( 'Display the layout switcher to allow the user to toggle between the list and grid layouts.', 'lsx-search' ),
339
-				)
340
-			);
341
-		}
342
-		if ( 'engine' === $section && function_exists('is_plugin_active') && is_plugin_active( 'tour-operator/tour-operator.php' ) ) {
343
-			$cmb->add_field(
344
-				array(
345
-					'name'    => esc_html__( 'List layout images', 'lsx-search' ),
346
-					'id'      => $section . '_search_list_layout_image_style',
347
-					'type'    => 'select',
348
-					'options' => array(
349
-						''           => esc_html__( 'Full Height', 'lsx-search' ),
350
-						'max-height' => esc_html__( 'Max Height', 'lsx-search' ),
351
-					),
352
-					'default' => '',
353
-				)
354
-			);
355
-		}
356
-		if ( 'engine' === $section ) {
357
-			$cmb->add_field(
358
-				array(
359
-					'name'        => esc_html__( 'Display Excerpt', 'lsx-search' ),
360
-					'id'          => $section . '_excerpt_enable',
361
-					'type'        => 'checkbox',
362
-					'description' => __( 'Display the excerpt of a listing.', 'lsx-search' ),
363
-				)
364
-			);
365
-			$cmb->add_field(
366
-				array(
367
-					'name'        => esc_html__( 'Enable Post Type Label', 'lsx-search' ),
368
-					'id'          => $section . '_search_enable_pt_label',
369
-					'type'        => 'checkbox',
370
-					'description' => __( 'This enables the post type label from entries on search results page.', 'lsx-search' ),
371
-				)
372
-			);
373
-			if ( function_exists('is_plugin_active') &&  is_plugin_active( 'tour-operator/tour-operator.php' ) ) {
374
-				$cmb->add_field(
375
-					array(
376
-						'name'        => esc_html__( 'Enable Continent Filter', 'lsx-search' ),
377
-						'id'          => $section . '_search_enable_continent_filter',
378
-						'type'        => 'checkbox',
379
-						'description' => __( 'This enables the continent filter in FacetWP destinations filter.', 'lsx-search' ),
380
-					)
381
-				);
382
-				$cmb->add_field(
383
-					array(
384
-						'name'        => esc_html__( 'Enable Continental Regions', 'lsx-search' ),
385
-						'id'          => $section . '_search_enable_continental_regions',
386
-						'type'        => 'checkbox',
387
-						'description' => __( 'This disable continents and enabled the sub regions.', 'lsx-search' ),
388
-					)
389
-				);
390
-			}
391
-		}
392
-
393
-		if ( function_exists('is_plugin_active') && is_plugin_active( 'tour-operator/tour-operator.php' ) && 'accommodation' === $section ) {
394
-			$cmb->add_field(
395
-				array(
396
-					'name'    => esc_html__( 'Results Layout - list vs map', 'lsx-search' ),
397
-					'id'      => $section . '_search_results_layout',
398
-					'type'    => 'select',
399
-					'options' => array(
400
-						'list_map'    => esc_html__( 'List and Map', 'lsx-search' ),
401
-						'list'        => esc_html__( 'List only', 'lsx-search' ),
402
-					),
403
-					'default' => '',
404
-				)
405
-			);
406
-		}
407
-
408
-		$cmb->add_field(
409
-			array(
410
-				'name'        => esc_html__( 'Enable Collapse', 'lsx-search' ),
411
-				'id'          => $section . '_search_collapse',
412
-				'type'        => 'checkbox',
413
-				'description' => __( 'Enable collapsible filters on search results.', 'lsx-search' ),
414
-			)
415
-		);
416
-
417
-		$cmb->add_field(
418
-			array(
419
-				'name' => esc_html__( 'Disable Sorting', 'lsx-search' ),
420
-				'id'   => $section . '_search_disable_sorting',
421
-				'type' => 'checkbox',
422
-				'description' => __( 'Toggle the sorting drop down menu on your search results.', 'lsx-search' ),
423
-			)
424
-		);
425
-
426
-		$cmb->add_field(
427
-			array(
428
-				'name' => esc_html__( 'Disable the Date Sorting Option', 'lsx-search' ),
429
-				'id'   => $section . '_search_disable_date',
430
-				'type' => 'checkbox',
431
-			)
432
-		);
433
-
434
-		$cmb->add_field(
435
-			array(
436
-				'name' => esc_html__( 'Display Clear Button', 'lsx-search' ),
437
-				'id'   => $section . '_search_display_clear_button',
438
-				'type' => 'checkbox',
439
-				'description' => __( 'Check this to turn on a button that will clear your search results.', 'lsx-search' ),
440
-			)
441
-		);
442
-
443
-		$cmb->add_field(
444
-			array(
445
-				'name' => esc_html__( 'Display Result Count', 'lsx-search' ),
446
-				'id'   => $section . '_search_display_result_count',
447
-				'type' => 'checkbox',
448
-			)
449
-		);
450
-		if ( function_exists('is_plugin_active') && is_plugin_active( 'facetwp-alpha/index.php' ) ) {
451
-			$cmb->add_field(
452
-				array(
453
-					'name'        => esc_html__( 'Alphabet Facet', 'lsx-search' ),
454
-					'description' => esc_html__( 'Select the alphabetical sorter facet.', 'lsx-search' ),
455
-					'id'          => $section . '_search_az_pagination',
456
-					'type'        => 'select',
457
-					'options'     => $this->az_facets,
458
-				)
459
-			);
460
-		}
461
-		$cmb->add_field(
462
-			array(
463
-				'name'        => esc_html__( 'Facets', 'lsx-search' ),
464
-				'description' => esc_html__( 'Choose the filters to display in the sidebar. Edit FacetWP filters to change individual filters.', 'lsx-search' ),
465
-				'id'          => $section . '_search_facets',
466
-				'type'        => 'multicheck',
467
-				'options'     => $this->facet_data,
468
-			)
469
-		);
470
-		do_action( 'lsx_search_settings_section', $cmb, 'bottom' );
471
-		$cmb->add_field(
472
-			array(
473
-				'id'   => 'settings_' . $section . '_search_closing',
474
-				'type' => 'tab_closing',
475
-			)
476
-		);
477
-	}
478
-
479
-	/**
480
-	 * Handle body colours that might be change by LSX Customiser.
481
-	 */
482
-	public function customizer_body_colours_handler( $css, $colors ) {
483
-		$css .= '
15
+     /**
16
+      * Holds class instance
17
+      *
18
+      * @since 1.0.0
19
+      *
20
+      * @var      object \lsx\search\classes\Admin()
21
+      */
22
+     protected static $instance = null;
23
+     /**
24
+      * Holds the options for the search.
25
+      *
26
+      * @var array()
27
+      */
28
+     public $options = false;
29
+
30
+     /**
31
+      * Holds the facetwp data for use in the fields.
32
+      *
33
+      * @var array()
34
+      */
35
+     public $facet_data = false;
36
+
37
+     /**
38
+      * Holds the Alpha betical facetwp data for use in the fields.
39
+      *
40
+      * @var array()
41
+      */
42
+     public $az_facets = array();
43
+
44
+     /**
45
+      * Holds the settings page theme functions
46
+      *
47
+      * @var object \lsx\search\classes\admin\Settings_Theme();
48
+      */
49
+     public $settings_theme;
50
+
51
+     /**
52
+      * Construct method.
53
+      */
54
+     public function __construct() {
55
+          $this->load_classes();
56
+          add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) );
57
+          add_action( 'lsx_search_settings_page', array( $this, 'configure_settings_search_engine_fields' ), 15, 1 );
58
+          add_action( 'lsx_search_settings_page', array( $this, 'configure_settings_search_archive_fields' ), 15, 1 );
59
+          add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) );
60
+
61
+          if ( is_admin() ) {
62
+               add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 );
63
+               add_filter( 'lsx_customizer_colour_selectors_button', array( $this, 'customizer_button_colours' ), 10, 2 );
64
+          }
65
+     }
66
+
67
+     /**
68
+      * Return an instance of this class.
69
+      *
70
+      * @since 1.0.0
71
+      *
72
+      * @return    object \lsx\member_directory\search\Admin()    A single instance of this class.
73
+      */
74
+     public static function get_instance() {
75
+          // If the single instance hasn't been set, set it now.
76
+          if ( null === self::$instance ) {
77
+               self::$instance = new self();
78
+          }
79
+          return self::$instance;
80
+     }
81
+
82
+     /**
83
+      * Loads the variable classes and the static classes.
84
+      */
85
+     private function load_classes() {
86
+          require_once LSX_SEARCH_PATH . 'classes/admin/class-settings-theme.php';
87
+          $this->settings_theme = admin\Settings_Theme::get_instance();
88
+     }
89
+
90
+     /**
91
+      * Configure Business Directory custom fields for the Settings page.
92
+      *
93
+      * @return void
94
+      */
95
+     public function register_settings_page() {
96
+          $args = array(
97
+               'id'           => 'lsx_search_settings',
98
+               'title'        => '<h1>' . esc_html__( 'LSX Search Settings', 'lsx-search' ) . ' <span class="version">' . LSX_SEARCH_VER . '</span></h1>',
99
+               'menu_title'   => esc_html__( 'LSX Search', 'search' ), // Falls back to 'title' (above).
100
+               'object_types' => array( 'options-page' ),
101
+               'option_key'   => 'lsx-search-settings', // The option key and admin menu page slug.
102
+               'parent_slug'  => 'options-general.php',
103
+               'capability'   => 'manage_options', // Cap required to view options-page.
104
+          );
105
+          $cmb  = new_cmb2_box( $args );
106
+          do_action( 'lsx_search_settings_page', $cmb );
107
+     }
108
+
109
+     /**
110
+      * Sets post types with active search options.
111
+      */
112
+     public function register_post_type_tabs( $post_types_plural ) {
113
+          $post_types_plural = array(
114
+               'project' => 'projects',
115
+               'service' => 'services',
116
+               'team' => 'team',
117
+               'testimonial' => 'testimonials',
118
+               'video' => 'videos',
119
+               'product' => 'products', // WooCommerce
120
+               'post' => 'posts',
121
+          );
122
+          return $post_types_plural;
123
+     }
124
+
125
+     /**
126
+      * Gets the Tour Operator Post Types.
127
+      *
128
+      * @return array
129
+      */
130
+     public function get_to_post_types() {
131
+          $to_types = array(
132
+               'accommodation',
133
+               'tour',
134
+               'destination',
135
+               'review',
136
+               'activity',
137
+               'special',
138
+               'vehicle',
139
+          );
140
+          return $to_types;
141
+     }
142
+
143
+     /**
144
+      * Sets the FacetWP variables.
145
+      *
146
+      * @return  void
147
+      */
148
+     public function set_facetwp_vars() {
149
+          if ( function_exists( '\FWP' ) ) {
150
+               $facet_data = \FWP()->helper->get_facets();
151
+          }
152
+          $this->facet_data = array();
153
+          $this->az_facets  = array(
154
+               '' => __( 'Do not show', 'lsx-search' ),
155
+          );
156
+          if ( ! empty( $facet_data ) && is_array( $facet_data ) ) {
157
+               foreach ( $facet_data as $facet ) {
158
+                    if ( 'alpha' === $facet['type'] ) {
159
+                         $this->az_facets[ $facet['name'] ] = $facet['label'] . '(' . $facet['name'] . ')';
160
+                    } else {
161
+                         $this->facet_data[ $facet['name'] ] = $facet['label'] . '(' . $facet['name'] . ')';
162
+                    }
163
+               }
164
+          }
165
+     }
166
+
167
+     /**
168
+      * Enqueue JS and CSS.
169
+      */
170
+     public function assets( $hook ) {
171
+          wp_enqueue_script( 'lsx-search-admin', LSX_SEARCH_URL . 'assets/js/src/lsx-search-admin.js', array( 'jquery' ), LSX_SEARCH_VER, true );
172
+          wp_enqueue_style( 'lsx-search-admin', LSX_SEARCH_URL . 'assets/css/lsx-search-admin.css', array(), LSX_SEARCH_VER );
173
+     }
174
+
175
+     /**
176
+      * Enable Business Directory Search settings only if LSX Search plugin is enabled.
177
+      *
178
+      * @return  void
179
+      */
180
+     public function configure_settings_search_engine_fields( $cmb ) {
181
+          $global_args = array(
182
+               'title' => __( 'Global', 'lsx-search' ),
183
+               'desc'  => esc_html__( 'Control the filters which show on your WordPress search results page.', 'lsx-search' ),
184
+          );
185
+          $this->search_fields( $cmb, 'engine', $global_args );
186
+     }
187
+
188
+     /**
189
+      * Enable Business Directory Search settings only if LSX Search plugin is enabled.
190
+      *
191
+      * @param object $cmb The CMB2() class.
192
+      * @param string $position either top of bottom.
193
+      * @return void
194
+      */
195
+     public function configure_settings_search_archive_fields( $cmb ) {
196
+          $archives       = array();
197
+          $post_type_args = array(
198
+               'public' => true,
199
+          );
200
+          $post_types     = get_post_types( $post_type_args );
201
+          if ( ! empty( $post_types ) ) {
202
+               foreach ( $post_types as $post_type_key => $post_type_value ) {
203
+                    switch ( $post_type_key ) {
204
+                         case 'post':
205
+                              $page_url      = home_url();
206
+                              $page_title    = __( 'Home', 'lsx-search' );
207
+                              $show_on_front = get_option( 'show_on_front' );
208
+                              if ( 'page' === $show_on_front ) {
209
+                                   $page_for_posts = get_option( 'page_for_posts' );
210
+                                   if ( '' !== $page_for_posts ) {
211
+                                        $page_title   = get_the_title( $page_for_posts );
212
+                                        $page_url     = get_permalink( $page_for_posts );
213
+                                   }
214
+                              }
215
+                              $description = sprintf(
216
+                                   /* translators: %s: The subscription info */
217
+                                   __( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> page.', 'lsx-search' ),
218
+                                   $page_url,
219
+                                   $page_title
220
+                              );
221
+                              $archives[ $post_type_key ] = array(
222
+                                   'title' => __( 'Blog', 'lsx-search' ),
223
+                                   'desc'  => $description,
224
+                              );
225
+                              break;
226
+
227
+                         case 'product':
228
+                              $page_url = home_url();
229
+                              $page_title    = __( 'Shop', 'lsx-search' );
230
+                              if ( function_exists( 'wc_get_page_id' ) ) {
231
+                                   $shop_page  = wc_get_page_id( 'shop' );
232
+                                   $page_url   = get_permalink( $shop_page );
233
+                                   $page_title = get_the_title( $shop_page );
234
+                              }
235
+                              $description = sprintf(
236
+                                   /* translators: %s: The subscription info */
237
+                                   __( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> page.', 'lsx-search' ),
238
+                                   $page_url,
239
+                                   $page_title
240
+                              );
241
+                              $archives[ $post_type_key ] = array(
242
+                                   'title' => __( 'Shop', 'lsx-search' ),
243
+                                   'desc'  => $description,
244
+                              );
245
+                              break;
246
+
247
+                         default:
248
+                              if ( ! in_array( $post_type_key, \lsx\search\includes\get_restricted_post_types() ) ) {
249
+                                   $temp_post_type = get_post_type_object( $post_type_key );
250
+                                   if ( ! is_wp_error( $temp_post_type ) ) {
251
+                                        $page_url    = get_post_type_archive_link( $temp_post_type->name );
252
+                                        $description = sprintf(
253
+                                             /* translators: %s: The subscription info */
254
+                                             __( 'Control the filters which show on your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ),
255
+                                             $page_url,
256
+                                             $temp_post_type->label
257
+                                        );
258
+
259
+                                        $archives[ $post_type_key ] = array(
260
+                                             'title' => $temp_post_type->label,
261
+                                             'desc'  => $description,
262
+                                        );
263
+                                   }
264
+                              }
265
+                              break;
266
+                    }
267
+               }
268
+          }
269
+          if ( ! empty( $archives ) ) {
270
+               foreach ( $archives as $archive_key => $archive_args ) {
271
+                    $this->search_fields( $cmb, $archive_key, $archive_args );
272
+               }
273
+          }
274
+     }
275
+
276
+     /**
277
+      * Enable Business Directory Search settings only if LSX Search plugin is enabled.
278
+      *
279
+      * @param object $cmb The CMB2() class.
280
+      * @param string $section either engine,archive or single.
281
+      * @return void
282
+      */
283
+     public function search_fields( $cmb, $section, $args ) {
284
+          $this->set_facetwp_vars();
285
+          $cmb->add_field(
286
+               array(
287
+                    'id'          => 'settings_' . $section . '_search',
288
+                    'type'        => 'title',
289
+                    'name'        => $args['title'],
290
+                    'default'     => $args['title'],
291
+                    'description' => $args['desc'],
292
+               )
293
+          );
294
+          do_action( 'lsx_search_settings_section', $cmb, 'top' );
295
+          $cmb->add_field(
296
+               array(
297
+                    'name'        => esc_html__( 'Enable Search Filters', 'lsx-search' ),
298
+                    'id'          => $section . '_search_enable',
299
+                    'description' => esc_html__( 'Display FacetWP filters on your search results page.', 'lsx-search' ),
300
+                    'type'        => 'checkbox',
301
+               )
302
+          );
303
+
304
+          $cmb->add_field(
305
+               array(
306
+                    'name'    => esc_html__( 'Page Layout', 'lsx-search' ),
307
+                    'id'      => $section . '_search_layout',
308
+                    'type'    => 'select',
309
+                    'options' => array(
310
+                         ''    => esc_html__( 'Follow the theme layout', 'lsx-search' ),
311
+                         '2cr' => esc_html__( 'Sidebar on left', 'lsx-search' ),
312
+                         '2cl' => esc_html__( 'Sidebar on right', 'lsx-search' ),
313
+                    ),
314
+                    'default' => '',
315
+               )
316
+          );
317
+
318
+          if ( 'product' === $section ) {
319
+               $cmb->add_field(
320
+                    array(
321
+                         'name'             => esc_html__( 'Results Layout', 'lsx-search' ),
322
+                         'id'               => $section . '_search_grid_list',
323
+                         'type'             => 'select',
324
+                         'show_option_none' => false,
325
+                         'description'      => __( 'Set a default layout for the search results.', 'lsx-search' ),
326
+                         'options'          => array(
327
+                              'grid' => esc_html__( 'Grid', 'lsx-search' ),
328
+                              'list' => esc_html__( 'List', 'lsx-search' ),
329
+                         ),
330
+                         'default' => 'grid',
331
+                    )
332
+               );
333
+               $cmb->add_field(
334
+                    array(
335
+                         'name'        => esc_html__( 'Layout Switcher', 'lsx-search' ),
336
+                         'id'          => $section . '_search_layout_switcher_enable',
337
+                         'type'        => 'checkbox',
338
+                         'description' => __( 'Display the layout switcher to allow the user to toggle between the list and grid layouts.', 'lsx-search' ),
339
+                    )
340
+               );
341
+          }
342
+          if ( 'engine' === $section && function_exists('is_plugin_active') && is_plugin_active( 'tour-operator/tour-operator.php' ) ) {
343
+               $cmb->add_field(
344
+                    array(
345
+                         'name'    => esc_html__( 'List layout images', 'lsx-search' ),
346
+                         'id'      => $section . '_search_list_layout_image_style',
347
+                         'type'    => 'select',
348
+                         'options' => array(
349
+                              ''           => esc_html__( 'Full Height', 'lsx-search' ),
350
+                              'max-height' => esc_html__( 'Max Height', 'lsx-search' ),
351
+                         ),
352
+                         'default' => '',
353
+                    )
354
+               );
355
+          }
356
+          if ( 'engine' === $section ) {
357
+               $cmb->add_field(
358
+                    array(
359
+                         'name'        => esc_html__( 'Display Excerpt', 'lsx-search' ),
360
+                         'id'          => $section . '_excerpt_enable',
361
+                         'type'        => 'checkbox',
362
+                         'description' => __( 'Display the excerpt of a listing.', 'lsx-search' ),
363
+                    )
364
+               );
365
+               $cmb->add_field(
366
+                    array(
367
+                         'name'        => esc_html__( 'Enable Post Type Label', 'lsx-search' ),
368
+                         'id'          => $section . '_search_enable_pt_label',
369
+                         'type'        => 'checkbox',
370
+                         'description' => __( 'This enables the post type label from entries on search results page.', 'lsx-search' ),
371
+                    )
372
+               );
373
+               if ( function_exists('is_plugin_active') &&  is_plugin_active( 'tour-operator/tour-operator.php' ) ) {
374
+                    $cmb->add_field(
375
+                         array(
376
+                              'name'        => esc_html__( 'Enable Continent Filter', 'lsx-search' ),
377
+                              'id'          => $section . '_search_enable_continent_filter',
378
+                              'type'        => 'checkbox',
379
+                              'description' => __( 'This enables the continent filter in FacetWP destinations filter.', 'lsx-search' ),
380
+                         )
381
+                    );
382
+                    $cmb->add_field(
383
+                         array(
384
+                              'name'        => esc_html__( 'Enable Continental Regions', 'lsx-search' ),
385
+                              'id'          => $section . '_search_enable_continental_regions',
386
+                              'type'        => 'checkbox',
387
+                              'description' => __( 'This disable continents and enabled the sub regions.', 'lsx-search' ),
388
+                         )
389
+                    );
390
+               }
391
+          }
392
+
393
+          if ( function_exists('is_plugin_active') && is_plugin_active( 'tour-operator/tour-operator.php' ) && 'accommodation' === $section ) {
394
+               $cmb->add_field(
395
+                    array(
396
+                         'name'    => esc_html__( 'Results Layout - list vs map', 'lsx-search' ),
397
+                         'id'      => $section . '_search_results_layout',
398
+                         'type'    => 'select',
399
+                         'options' => array(
400
+                              'list_map'    => esc_html__( 'List and Map', 'lsx-search' ),
401
+                              'list'        => esc_html__( 'List only', 'lsx-search' ),
402
+                         ),
403
+                         'default' => '',
404
+                    )
405
+               );
406
+          }
407
+
408
+          $cmb->add_field(
409
+               array(
410
+                    'name'        => esc_html__( 'Enable Collapse', 'lsx-search' ),
411
+                    'id'          => $section . '_search_collapse',
412
+                    'type'        => 'checkbox',
413
+                    'description' => __( 'Enable collapsible filters on search results.', 'lsx-search' ),
414
+               )
415
+          );
416
+
417
+          $cmb->add_field(
418
+               array(
419
+                    'name' => esc_html__( 'Disable Sorting', 'lsx-search' ),
420
+                    'id'   => $section . '_search_disable_sorting',
421
+                    'type' => 'checkbox',
422
+                    'description' => __( 'Toggle the sorting drop down menu on your search results.', 'lsx-search' ),
423
+               )
424
+          );
425
+
426
+          $cmb->add_field(
427
+               array(
428
+                    'name' => esc_html__( 'Disable the Date Sorting Option', 'lsx-search' ),
429
+                    'id'   => $section . '_search_disable_date',
430
+                    'type' => 'checkbox',
431
+               )
432
+          );
433
+
434
+          $cmb->add_field(
435
+               array(
436
+                    'name' => esc_html__( 'Display Clear Button', 'lsx-search' ),
437
+                    'id'   => $section . '_search_display_clear_button',
438
+                    'type' => 'checkbox',
439
+                    'description' => __( 'Check this to turn on a button that will clear your search results.', 'lsx-search' ),
440
+               )
441
+          );
442
+
443
+          $cmb->add_field(
444
+               array(
445
+                    'name' => esc_html__( 'Display Result Count', 'lsx-search' ),
446
+                    'id'   => $section . '_search_display_result_count',
447
+                    'type' => 'checkbox',
448
+               )
449
+          );
450
+          if ( function_exists('is_plugin_active') && is_plugin_active( 'facetwp-alpha/index.php' ) ) {
451
+               $cmb->add_field(
452
+                    array(
453
+                         'name'        => esc_html__( 'Alphabet Facet', 'lsx-search' ),
454
+                         'description' => esc_html__( 'Select the alphabetical sorter facet.', 'lsx-search' ),
455
+                         'id'          => $section . '_search_az_pagination',
456
+                         'type'        => 'select',
457
+                         'options'     => $this->az_facets,
458
+                    )
459
+               );
460
+          }
461
+          $cmb->add_field(
462
+               array(
463
+                    'name'        => esc_html__( 'Facets', 'lsx-search' ),
464
+                    'description' => esc_html__( 'Choose the filters to display in the sidebar. Edit FacetWP filters to change individual filters.', 'lsx-search' ),
465
+                    'id'          => $section . '_search_facets',
466
+                    'type'        => 'multicheck',
467
+                    'options'     => $this->facet_data,
468
+               )
469
+          );
470
+          do_action( 'lsx_search_settings_section', $cmb, 'bottom' );
471
+          $cmb->add_field(
472
+               array(
473
+                    'id'   => 'settings_' . $section . '_search_closing',
474
+                    'type' => 'tab_closing',
475
+               )
476
+          );
477
+     }
478
+
479
+     /**
480
+      * Handle body colours that might be change by LSX Customiser.
481
+      */
482
+     public function customizer_body_colours_handler( $css, $colors ) {
483
+          $css .= '
484 484
 			@import "' . LSX_SEARCH_PATH . '/assets/css/scss/customizer-search-body-colours";
485 485
 
486 486
 			/**
@@ -496,18 +496,18 @@  discard block
 block discarded – undo
496 496
 			);
497 497
 		';
498 498
 
499
-		return $css;
500
-	}
501
-
502
-	/**
503
-	 * Adds the lsx search buttons to the customizer plugin.
504
-	 *
505
-	 * @param string $css
506
-	 * @param array $colours
507
-	 * @return string
508
-	 */
509
-	public function customizer_button_colours( $css, $colours ) {
510
-		$css .= '
499
+          return $css;
500
+     }
501
+
502
+     /**
503
+      * Adds the lsx search buttons to the customizer plugin.
504
+      *
505
+      * @param string $css
506
+      * @param array $colours
507
+      * @return string
508
+      */
509
+     public function customizer_button_colours( $css, $colours ) {
510
+          $css .= '
511 511
 			#secondary.facetwp-sidebar {
512 512
 				.facetwp-item.facetwp-form {
513 513
 					.search-form {
@@ -520,6 +520,6 @@  discard block
 block discarded – undo
520 520
 				}
521 521
 			}
522 522
 		';
523
-		return $css;
524
-	}
523
+          return $css;
524
+     }
525 525
 }
Please login to merge, or discard this patch.
classes/class-frontend.php 1 patch
Indentation   +968 added lines, -968 removed lines patch added patch discarded remove patch
@@ -9,686 +9,686 @@  discard block
 block discarded – undo
9 9
 
10 10
 class Frontend {
11 11
 
12
-	/**
13
-	 * Holds class instance
14
-	 *
15
-	 * @since 1.0.0
16
-	 *
17
-	 * @var      object \lsx\search\classes\Frontend()
18
-	 */
19
-	protected static $instance = null;
20
-
21
-	public $options = false;
22
-
23
-	public $tabs = false;
24
-
25
-	public $facet_data = false;
26
-
27
-	/**
28
-	 * Determine weather or not search is enabled for this page.
29
-	 *
30
-	 * @var boolean
31
-	 */
32
-	public $search_enabled = false;
33
-
34
-	public $search_core_suffix = false;
35
-
36
-	public $search_prefix = false;
37
-
38
-	/**
39
-	 * Holds the post types enabled
40
-	 *
41
-	 * @var array
42
-	 */
43
-	public $post_types = array();
44
-
45
-	/**
46
-	 * Holds the taxonomies enabled for search
47
-	 *
48
-	 * @var array
49
-	 */
50
-	public $taxonomies = array();
51
-
52
-	/**
53
-	 * If the current search page has posts or not
54
-	 *
55
-	 * @var boolean
56
-	 */
57
-	public $has_posts = false;
58
-
59
-	/**
60
-	 * If we are using the CMB2 options or not.
61
-	 *
62
-	 * @var boolean
63
-	 */
64
-	public $new_options = false;
65
-
66
-	/**
67
-	 * Construct method.
68
-	 */
69
-	public function __construct() {
70
-		$this->options = \lsx\search\includes\get_options();
71
-		$this->load_classes();
72
-
73
-		add_filter( 'wpseo_json_ld_search_url', array( $this, 'change_json_ld_search_url' ), 10, 1 );
74
-		add_action( 'wp', array( $this, 'set_vars' ), 21 );
75
-		add_action( 'wp', array( $this, 'set_facetwp_vars' ), 22 );
76
-		add_action( 'wp', array( $this, 'core' ), 23 );
77
-		add_action( 'lsx_body_top', array( $this, 'check_for_results' ) );
78
-
79
-		add_filter( 'pre_get_posts', array( $this, 'ignore_sticky_search' ) );
80
-		add_action( 'pre_get_posts', array( $this, 'filter_post_types' ) );
81
-
82
-		add_filter( 'lsx_search_post_types', array( $this, 'register_post_types' ) );
83
-		add_filter( 'lsx_search_taxonomies', array( $this, 'register_taxonomies' ) );
84
-		add_filter( 'lsx_search_post_types_plural', array( $this, 'register_post_type_tabs' ) );
85
-		add_filter( 'facetwp_sort_options', array( $this, 'facetwp_sort_options' ), 10, 2 );
86
-		add_filter( 'wp_kses_allowed_html', array( $this, 'kses_allowed_html' ), 20, 2 );
87
-		add_filter( 'get_search_query', array( $this, 'get_search_query' ) );
88
-
89
-		// Redirects.
90
-		add_action( 'template_redirect', array( $this, 'pretty_search_redirect' ) );
91
-		add_filter( 'pre_get_posts', array( $this, 'pretty_search_parse_query' ) );
92
-
93
-		add_action( 'lsx_search_sidebar_top', array( $this, 'search_sidebar_top' ) );
94
-		add_filter( 'facetwp_facet_html', array( $this, 'search_facet_html' ), 10, 2 );
95
-	}
96
-
97
-	/**
98
-	 * Return an instance of this class.
99
-	 *
100
-	 * @since 1.0.0
101
-	 *
102
-	 * @return    object \lsx\member_directory\search\Frontend()    A single instance of this class.
103
-	 */
104
-	public static function get_instance() {
105
-		// If the single instance hasn't been set, set it now.
106
-		if ( null === self::$instance ) {
107
-			self::$instance = new self();
108
-		}
109
-		return self::$instance;
110
-	}
111
-
112
-	/**
113
-	 * Loads the variable classes and the static classes.
114
-	 */
115
-	private function load_classes() {
116
-		require_once LSX_SEARCH_PATH . 'classes/frontend/class-layout.php';
117
-		$this->layout = frontend\Layout::get_instance();
118
-	}
119
-
120
-	/**
121
-	 * Check all settings.
122
-	 */
123
-	public function set_vars() {
124
-		$post_type = '';
125
-
126
-		$this->post_types      = apply_filters( 'lsx_search_post_types', array() );
127
-		$this->taxonomies      = apply_filters( 'lsx_search_taxonomies', array() );
128
-		$this->tabs            = apply_filters( 'lsx_search_post_types_plural', array() );
129
-		$this->options         = apply_filters( 'lsx_search_options', $this->options );
130
-		$this->post_types      = get_post_types();
131
-		$this->post_type_slugs = array(
132
-			'post'        => 'posts',
133
-			'project'     => 'projects',
134
-			'service'     => 'services',
135
-			'team'        => 'team',
136
-			'testimonial' => 'testimonials',
137
-			'video'       => 'videos',
138
-			'product'     => 'products',
139
-		);
140
-		$this->set_search_prefix();
141
-		$this->get_cmb2_options();
142
-		$this->search_enabled = apply_filters( 'lsx_search_enabled', $this->is_search_enabled(), $this );
143
-		$this->search_prefix  = apply_filters( 'lsx_search_prefix', $this->search_prefix, $this );
144
-	}
145
-
146
-	private function get_cmb2_options() {
147
-		$cmb2_options = get_option( 'lsx-search-settings' );
148
-		if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) {
149
-			$this->set_search_prefix( true );
150
-			$this->options['display'] = $cmb2_options;
151
-			foreach ( $this->options['display'] as $option_key => $option_value ) {
152
-				if ( is_array( $option_value ) && ! empty( $option_value ) ) {
153
-					$new_values = array();
154
-					foreach ( $option_value as $empty_key => $key_value ) {
155
-						$new_values[ $key_value ] = 'on';
156
-					}
157
-					$this->options['display'][ $option_key ] = $new_values;
158
-				}
159
-			}
160
-			$this->new_options = true;
161
-			$this->disable_to_search_actions();
162
-		}
163
-	}
164
-
165
-	private function disable_to_search_actions() {
166
-		global $lsx_to_search_fwp, $lsx_to_search;
167
-		if ( null !== $lsx_to_search ) {
168
-			// Redirects.
169
-			remove_filter( 'template_include', array( $lsx_to_search, 'search_template_include' ), 99 );
170
-			remove_action( 'template_redirect', array( $lsx_to_search, 'pretty_search_redirect' ) );
171
-			remove_filter( 'pre_get_posts', array( $lsx_to_search, 'pretty_search_parse_query' ) );
172
-
173
-			// Layout Filter.
174
-			remove_filter( 'lsx_layout', array( $lsx_to_search, 'lsx_layout' ), 20, 1 );
175
-			remove_filter( 'lsx_layout_selector', array( $lsx_to_search, 'lsx_layout_selector' ), 10, 4 );
176
-			remove_filter( 'lsx_to_archive_layout', array( $lsx_to_search, 'lsx_to_search_archive_layout' ), 10, 2 );
177
-
178
-			remove_action( 'lsx_search_sidebar_top', array( $lsx_to_search, 'search_sidebar_top' ) );
179
-			remove_action( 'pre_get_posts', array( $lsx_to_search, 'price_sorting' ), 100 );
180
-
181
-			//add_shortcode( 'lsx_search_form', array( 'LSX_TO_Search_Frontend', 'search_form' ) );
182
-			remove_filter( 'searchwp_short_circuit', array( $lsx_to_search, 'searchwp_short_circuit' ), 10, 2 );
183
-			remove_filter( 'get_search_query', array( $lsx_to_search, 'get_search_query' ) );
184
-			remove_filter( 'body_class', array( $lsx_to_search, 'to_add_search_url_class' ), 20 );
185
-
186
-			remove_filter( 'facetwp_preload_url_vars', array( $lsx_to_search, 'preload_url_vars' ), 10, 1 );
187
-			remove_filter( 'wpseo_json_ld_search_url', array( $lsx_to_search, 'change_json_ld_search_url' ), 10, 1 );
188
-		}
189
-		if ( null !== $lsx_to_search_fwp ) {
190
-			remove_filter( 'facetwp_indexer_row_data', array( $lsx_to_search_fwp, 'facetwp_index_row_data' ), 10, 2 );
191
-			remove_filter( 'facetwp_index_row', array( $lsx_to_search_fwp, 'facetwp_index_row' ), 10, 2 );
192
-
193
-			remove_filter( 'facetwp_sort_options', array( $lsx_to_search_fwp, 'facet_sort_options' ), 10, 2 );
194
-
195
-			remove_filter( 'facetwp_pager_html', array( $lsx_to_search_fwp, 'facetwp_pager_html' ), 10, 2 );
196
-			remove_filter( 'facetwp_result_count', array( $lsx_to_search_fwp, 'facetwp_result_count' ), 10, 2 );
197
-
198
-			remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'destination_facet_html' ), 10, 2 );
199
-			remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'slide_facet_html' ), 10, 2 );
200
-			remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'search_facet_html' ), 10, 2 );
201
-			remove_filter( 'facetwp_load_css', array( $lsx_to_search_fwp, 'facetwp_load_css' ), 10, 1 );
202
-
203
-			if ( class_exists( 'LSX_Currencies' ) ) {
204
-				remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_lsx_currencies' ), 10, 2 );
205
-			} else {
206
-				remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_to_currencies' ), 10, 2 );
207
-			}
208
-		}
209
-	}
210
-
211
-	/**
212
-	 * Returns if the search is enabled.
213
-	 *
214
-	 * @return boolean
215
-	 */
216
-	public function is_search_enabled() {
217
-		$search_enabled = false;
218
-
219
-		if ( false === $this->new_options ) {
220
-			if ( isset( $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) && ( ! empty( $this->options ) ) && 'on' == $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) {
221
-				$search_enabled = true;
222
-			}
223
-		} else {
224
-			$enable_prefix = $this->search_prefix;
225
-			if ( ! empty( $this->options ) && isset( $this->options['display'] ) && isset( $this->options['display'][ $enable_prefix . '_enable' ] ) && 'on' === $this->options['display'][ $enable_prefix . '_enable' ] ) {
226
-				$search_enabled = true;
227
-			}
228
-		}
229
-
230
-		// These are specific plugin exclusions.
231
-		if ( is_tax( array( 'wcpv_product_vendors' ) ) ) {
232
-			$search_enabled = false;
233
-		}
234
-		return $search_enabled;
235
-	}
236
-
237
-	/**
238
-	 * Sets the search prefix.
239
-	 *
240
-	 * @return void
241
-	 */
242
-	private function set_search_prefix( $new_prefixes = false ) {
243
-		$page_for_posts = get_option( 'page_for_posts' );
244
-		if ( false !== $new_prefixes ) {
245
-			$this->taxonomies = array();
246
-			$this->post_types = array();
247
-		}
248
-
249
-		if ( is_search() ) {
250
-			if ( false === $new_prefixes ) {
251
-				$this->search_core_suffix = 'core';
252
-				$this->search_prefix      = 'search';
253
-			} else {
254
-				$this->search_core_suffix = 'enable';
255
-				$this->search_prefix      = 'engine_search';
256
-			}
257
-		} elseif ( is_post_type_archive( $this->post_types ) || is_tax() || is_page( $page_for_posts ) || is_home() || is_category() || is_tag() ) {
258
-			if ( false === $new_prefixes ) {
259
-				$this->search_core_suffix = 'search';
260
-			} else {
261
-				$this->search_core_suffix = 'enable';
262
-			}
263
-
264
-			if ( is_tax() ) {
265
-				$tax = get_query_var( 'taxonomy' );
266
-				$tax = get_taxonomy( $tax );
267
-				$post_type = $tax->object_type[0];
268
-			} else if ( is_page( $page_for_posts ) || is_category() || is_tag() || is_home() ) {
269
-				$post_type = 'post';
270
-			} else {
271
-				$post_type = get_query_var( 'post_type' );
272
-			}
273
-
274
-			if ( false === $new_prefixes ) {
275
-				if ( isset( $this->tabs[ $post_type ] ) ) {
276
-					$this->search_prefix = $this->tabs[ $post_type ] . '_archive';
277
-				}
278
-			} else {
279
-				$this->search_prefix = $post_type . '_search';
280
-			}
281
-		}
282
-	}
283
-
284
-	/**
285
-	 * Sets the FacetWP variables.
286
-	 */
287
-	public function set_facetwp_vars() {
288
-
289
-		if ( class_exists( 'FacetWP' ) ) {
290
-			$facet_data = FWP()->helper->get_facets();
291
-		}
292
-
293
-		$this->facet_data = array();
294
-
295
-		$this->facet_data['search_form'] = array(
296
-			'name' => 'search_form',
297
-			'label' => esc_html__( 'Search Form', 'lsx-search' ),
298
-		);
299
-
300
-		if ( ! empty( $facet_data ) && is_array( $facet_data ) ) {
301
-			foreach ( $facet_data as $facet ) {
302
-				$this->facet_data[ $facet['name'] ] = $facet;
303
-			}
304
-		}
305
-	}
306
-
307
-	/**
308
-	 * Check all settings.
309
-	 */
310
-	public function core() {
311
-
312
-		if ( true === $this->search_enabled ) {
313
-			add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 999 );
314
-
315
-			add_filter( 'lsx_layout', array( $this, 'lsx_layout' ), 20, 1 );
316
-			add_filter( 'lsx_layout_selector', array( $this, 'lsx_layout_selector' ), 10, 4 );
317
-			add_filter( 'lsx_slot_class', array( $this, 'change_slot_column_class' ) );
318
-			add_action( 'lsx_entry_top', array( $this, 'add_label_to_title' ) );
319
-			add_filter( 'body_class', array( $this, 'body_class' ), 10 );
320
-
321
-			add_filter( 'lsx_blog_customizer_top_of_blog_action', array( $this, 'top_of_blog_action' ), 10, 1 );
322
-			add_filter( 'lsx_blog_customizer_blog_description_class', array( $this, 'blog_description_class' ), 10, 1 );
323
-
324
-			if ( class_exists( 'LSX_Videos' ) ) {
325
-				global $lsx_videos_frontend;
326
-				remove_action( 'lsx_content_top', array( $lsx_videos_frontend, 'categories_tabs' ), 15 );
327
-			}
328
-
329
-			add_filter( 'lsx_paging_nav_disable', '__return_true' );
330
-			add_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) );
331
-			add_action( 'lsx_content_top', array( $this, 'facetwp_tempate_open' ) );
332
-			add_action( 'lsx_content_bottom', array( $this, 'facetwp_tempate_close' ) );
333
-			add_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) );
334
-
335
-			if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) && '1c' !== $this->options['display'][ $this->search_prefix . '_layout' ] ) {
336
-				add_filter( 'lsx_sidebar_enable', array( $this, 'lsx_sidebar_enable' ), 10, 1 );
337
-			}
338
-
339
-			add_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 );
340
-
341
-			if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) {
342
-				remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
343
-				remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' );
344
-				add_filter( 'woocommerce_show_page_title', '__return_false' );
345
-
346
-				add_filter( 'loop_shop_columns', function() {
347
-					return 3;
348
-				} );
349
-
350
-				// Actions added by LSX theme
351
-				remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
352
-				add_action( 'lsx_content_wrap_before', array( $this, 'wc_archive_header' ), 140 );
353
-
354
-				// Actions added be LSX theme / woocommerce.php file
355
-				remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 );
356
-				remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
357
-				remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
358
-				remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 );
359
-				remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 );
360
-
361
-				// Actions added be LSX theme / woocommerce.php file
362
-				remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 );
363
-				remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
364
-				remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
365
-				remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 );
366
-				remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 );
367
-			}
368
-		}
369
-	}
370
-
371
-	/**
372
-	 * Adds a search class to the body to allow the styling of the sidebars etc.
373
-	 *
374
-	 * @param  array $classes The classes.
375
-	 * @return array $classes The classes.
376
-	 */
377
-	public function body_class( $classes ) {
378
-		$classes[] = 'lsx-search-enabled';
379
-		return $classes;
380
-	}
381
-
382
-	/**
383
-	 * Moves the blog description to above the content columns.
384
-	 *
385
-	 * @param  string $action
386
-	 * @return string $action
387
-	 */
388
-	public function top_of_blog_action( $action = '' ) {
389
-		$action = 'lsx_content_wrap_before';
390
-		return $action;
391
-	}
392
-
393
-	/**
394
-	 * Adds a class to the blog description.
395
-	 *
396
-	 * @param  string $action
397
-	 * @return string $action
398
-	 */
399
-	public function blog_description_class( $class = '' ) {
400
-		$class .= ' col-md-12 search-description';
401
-		return $class;
402
-	}
403
-
404
-	/**
405
-	 * Check the $wp_query global to see if there are posts in the current query.
406
-	 *
407
-	 * @return void
408
-	 */
409
-	public function check_for_results() {
410
-		if ( true === $this->search_enabled ) {
411
-			global $wp_query;
412
-			if ( empty( $wp_query->posts ) ) {
413
-				$this->has_posts = false;
414
-				remove_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) );
415
-				remove_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) );
416
-				remove_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 );
417
-			} else {
418
-				$this->has_posts = true;
419
-			}
420
-		}
421
-	}
422
-
423
-	/**
424
-	 * Filter the post types.
425
-	 */
426
-	public function filter_post_types( $query ) {
427
-		if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
428
-			if ( ! empty( $this->options ) && ! empty( $this->options['display']['search_enable_core'] ) ) {
429
-				if ( ! empty( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) {
430
-					$post_types = array_keys( $this->options['general']['search_post_types'] );
431
-					$query->set( 'post_type', $post_types );
432
-				}
433
-			}
434
-		}
435
-	}
436
-
437
-	/**
438
-	 * Sets post types with active search options.
439
-	 */
440
-	public function register_post_types( $post_types ) {
441
-		$post_types = array( 'post', 'project', 'service', 'team', 'testimonial', 'video', 'product' );
442
-		return $post_types;
443
-	}
444
-
445
-	/**
446
-	 * Sets taxonomies with active search options.
447
-	 */
448
-	public function register_taxonomies( $taxonomies ) {
449
-		$taxonomies = array( 'category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag' );
450
-		return $taxonomies;
451
-	}
452
-
453
-	/**
454
-	 * Sets post types with active search options.
455
-	 */
456
-	public function register_post_type_tabs( $post_types_plural ) {
457
-		$post_types_plural = array(
458
-			'post' => 'posts',
459
-			'project' => 'projects',
460
-			'service' => 'services',
461
-			'team' => 'team',
462
-			'testimonial' => 'testimonials',
463
-			'video' => 'videos',
464
-			'product' => 'products', // WooCommerce
465
-		);
466
-		return $post_types_plural;
467
-	}
468
-
469
-	/**
470
-	 * Enqueue styles and scripts.
471
-	 */
472
-	public function assets() {
473
-		add_filter( 'lsx_defer_parsing_of_js', array( $this, 'skip_js_defer' ), 10, 4 );
474
-		wp_enqueue_script( 'touchSwipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.touchSwipe.min.js', array( 'jquery' ), LSX_SEARCH_VER, true );
475
-		wp_enqueue_script( 'slideandswipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.slideandswipe.min.js', array( 'jquery', 'touchSwipe' ), LSX_SEARCH_VER, true );
476
-		wp_enqueue_script( 'lsx-search', LSX_SEARCH_URL . 'assets/js/src/lsx-search.js', array( 'jquery', 'touchSwipe', 'slideandswipe', 'jquery-ui-datepicker' ), LSX_SEARCH_VER, true );
477
-
478
-		$params = apply_filters( 'lsx_search_js_params', array(
479
-			'ajax_url' => admin_url( 'admin-ajax.php' ),
480
-		));
481
-
482
-		wp_localize_script( 'lsx-search', 'lsx_customizer_params', $params );
483
-
484
-		wp_enqueue_style( 'lsx-search', LSX_SEARCH_URL . 'assets/css/lsx-search.css', array(), LSX_SEARCH_VER );
485
-		wp_style_add_data( 'lsx-search', 'rtl', 'replace' );
486
-
487
-		if ( true === $this->new_options ) {
488
-			wp_deregister_style( 'lsx_to_search' );
489
-			wp_deregister_script( 'lsx_to_search' );
490
-		}
491
-	}
492
-
493
-	/**
494
-	 * Adds the to-search.min.js and the to-search.js
495
-	 *
496
-	 * @param boolean $should_skip
497
-	 * @param string  $tag
498
-	 * @param string  $handle
499
-	 * @param string  $href
500
-	 * @return boolean
501
-	 */
502
-	public function skip_js_defer( $should_skip, $tag, $handle, $href ) {
503
-		if ( ! is_admin() && ( false !== stripos( $href, 'lsx-search.min.js' ) || false !== stripos( $href, 'lsx-search.js' ) ) ) {
504
-			$should_skip = true;
505
-		}
506
-		return $should_skip;
507
-	}
508
-
509
-	/**
510
-	 * Redirect wordpress to the search template located in the plugin
511
-	 *
512
-	 * @param	$template
513
-	 * @return	$template
514
-	 */
515
-	public function search_template_include( $template ) {
516
-		if ( is_main_query() && is_search() ) {
517
-			if ( file_exists( LSX_SEARCH_PATH . 'templates/search.php' ) ) {
518
-				$template = LSX_SEARCH_PATH . 'templates/search.php';
519
-			}
520
-		}
521
-
522
-		return $template;
523
-	}
524
-
525
-	/**
526
-	 * Ignore sticky posts on Blog search.
527
-	 *
528
-	 * @param [type] $query
529
-	 * @return void
530
-	 */
531
-	public function ignore_sticky_search( $query ) {
532
-		if ( $query->is_main_query() && is_home() ) {
533
-			$query->set( 'ignore_sticky_posts', true );
534
-		}
535
-	}
536
-
537
-	/**
538
-	 * Rewrite the search URL
539
-	 */
540
-	public function pretty_search_redirect() {
541
-		global $wp_rewrite,$wp_query;
542
-
543
-		if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) {
544
-			return;
545
-		}
546
-
547
-		$search_base = $wp_rewrite->search_base;
548
-
549
-		if ( is_search() && ! is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) {
550
-			$search_query = get_query_var( 's' );
551
-			if ( empty( $search_query ) && isset( $_GET['s'] ) ) {
552
-				$search_query = $_GET['s'];
553
-			}
554
-			$engine = '';
555
-
556
-			// If the search was triggered by a supplemental engine.
557
-			if ( isset( $_GET['engine'] ) && 'default' !== $_GET['engine'] ) {
558
-				$engine = sanitize_text_field( wp_unslash( $_GET['engine'] ) );
559
-				$index  = array_search( $engine, $this->post_type_slugs, true );
560
-				if ( false !== $index ) {
561
-					$engine = $index;
562
-				}
563
-				$engine = $engine . '/';
564
-			}
565
-
566
-			$get_array = $_GET;
567
-
568
-			if ( is_array( $get_array ) && ! empty( $get_array ) ) {
569
-				$vars_to_maintain = array();
570
-
571
-				foreach ( $get_array as $ga_key => $ga_value ) {
572
-					if ( false !== strpos( $ga_key, 'fwp_' ) ) {
573
-						$vars_to_maintain[] = $ga_key . '=' . $ga_value;
574
-					}
575
-				}
576
-			}
577
-
578
-			$redirect_url = home_url( "/{$search_base}/" . $engine . urlencode( $search_query ) );
579
-
580
-			if ( ! empty( $vars_to_maintain ) ) {
581
-				$redirect_url .= '?' . implode( '&', $vars_to_maintain );
582
-			}
583
-			wp_redirect( $redirect_url );
584
-			exit();
585
-		}
586
-	}
587
-
588
-	/**
589
-	 * Parse the Query and trigger a search
590
-	 */
591
-	public function pretty_search_parse_query( $query ) {
592
-		$this->post_type_slugs = array(
593
-			'post' => 'posts',
594
-			'project' => 'projects',
595
-			'service' => 'services',
596
-			'team' => 'team',
597
-			'testimonial' => 'testimonials',
598
-			'video' => 'videos',
599
-			'product' => 'products', // WooCommerce
600
-		);
601
-		if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) {
602
-			$search_query = $query->get( 's' );
603
-			$keyword_test = explode( '/', $search_query );
604
-
605
-			$index = array_search( $keyword_test[0], $this->post_type_slugs, true );
606
-			if ( false !== $index ) {
607
-				$engine = $this->post_type_slugs[ $index ];
608
-
609
-				$query->set( 'post_type', $engine );
610
-				$query->set( 'engine', $engine );
611
-
612
-				if ( count( $keyword_test ) > 1 ) {
613
-					$query->set( 's', $keyword_test[1] );
614
-				} elseif ( post_type_exists( $engine ) ) {
615
-					$query->set( 's', '' );
616
-				}
617
-			} else {
618
-				if ( isset( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) {
619
-					$post_types = array_keys( $this->options['general']['search_post_types'] );
620
-					$query->set( 'post_type', $post_types );
621
-				}
622
-			}
623
-		}
624
-		return $query;
625
-	}
626
-
627
-	/**
628
-	 * Change the search slug to /search/ for the JSON+LD output in Yoast SEO
629
-	 *
630
-	 * @return url
631
-	 */
632
-	public function change_json_ld_search_url() {
633
-		return trailingslashit( home_url() ) . 'search/{search_term_string}';
634
-	}
635
-
636
-	/**
637
-	 * A filter to set the layout to 2 column.
638
-	 */
639
-	public function lsx_layout( $layout ) {
640
-		if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) {
641
-			if ( false === $this->has_posts ) {
642
-				$layout = '1c';
643
-			} else {
644
-				$layout = $this->options['display'][ $this->search_prefix . '_layout' ];
645
-			}
646
-		}
647
-		return $layout;
648
-	}
649
-
650
-	/**
651
-	 * Outputs the Search Title Facet
652
-	 */
653
-	public function search_sidebar_top() {
654
-		if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) && true !== apply_filters( 'lsx_search_hide_search_box', false ) ) {
655
-
656
-			if ( ! is_search() ) {
657
-
658
-				foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) {
659
-
660
-					if ( isset( $this->facet_data[ $facet ] ) && 'search' === $this->facet_data[ $facet ]['type'] ) {
661
-						echo wp_kses_post( '<div class="row">' );
662
-							$this->display_facet_default( $facet );
663
-						echo wp_kses_post( '</div>' );
664
-						unset( $this->options['display'][ $this->search_prefix . '_facets' ][ $facet ] );
665
-					}
666
-				}
667
-			} else {
668
-				echo wp_kses_post( '<div class="row">' );
669
-					$this->display_facet_search();
670
-				echo wp_kses_post( '</div>' );
671
-			}
672
-		}
673
-	}
674
-
675
-	/**
676
-	 * Overrides the search facet HTML
677
-	 * @param $output
678
-	 * @param $params
679
-	 *
680
-	 * @return string
681
-	 */
682
-	public function search_facet_html( $output, $params ) {
683
-		if ( 'search' == $params['facet']['type'] ) {
684
-
685
-			$value = (array) $params['selected_values'];
686
-			$value = empty( $value ) ? '' : stripslashes( $value[0] );
687
-			$placeholder = isset( $params['facet']['placeholder'] ) ? $params['facet']['placeholder'] : __( 'Search...', 'lsx-search' );
688
-			$placeholder = facetwp_i18n( $placeholder );
689
-
690
-			ob_start();
691
-			?>
12
+     /**
13
+      * Holds class instance
14
+      *
15
+      * @since 1.0.0
16
+      *
17
+      * @var      object \lsx\search\classes\Frontend()
18
+      */
19
+     protected static $instance = null;
20
+
21
+     public $options = false;
22
+
23
+     public $tabs = false;
24
+
25
+     public $facet_data = false;
26
+
27
+     /**
28
+      * Determine weather or not search is enabled for this page.
29
+      *
30
+      * @var boolean
31
+      */
32
+     public $search_enabled = false;
33
+
34
+     public $search_core_suffix = false;
35
+
36
+     public $search_prefix = false;
37
+
38
+     /**
39
+      * Holds the post types enabled
40
+      *
41
+      * @var array
42
+      */
43
+     public $post_types = array();
44
+
45
+     /**
46
+      * Holds the taxonomies enabled for search
47
+      *
48
+      * @var array
49
+      */
50
+     public $taxonomies = array();
51
+
52
+     /**
53
+      * If the current search page has posts or not
54
+      *
55
+      * @var boolean
56
+      */
57
+     public $has_posts = false;
58
+
59
+     /**
60
+      * If we are using the CMB2 options or not.
61
+      *
62
+      * @var boolean
63
+      */
64
+     public $new_options = false;
65
+
66
+     /**
67
+      * Construct method.
68
+      */
69
+     public function __construct() {
70
+          $this->options = \lsx\search\includes\get_options();
71
+          $this->load_classes();
72
+
73
+          add_filter( 'wpseo_json_ld_search_url', array( $this, 'change_json_ld_search_url' ), 10, 1 );
74
+          add_action( 'wp', array( $this, 'set_vars' ), 21 );
75
+          add_action( 'wp', array( $this, 'set_facetwp_vars' ), 22 );
76
+          add_action( 'wp', array( $this, 'core' ), 23 );
77
+          add_action( 'lsx_body_top', array( $this, 'check_for_results' ) );
78
+
79
+          add_filter( 'pre_get_posts', array( $this, 'ignore_sticky_search' ) );
80
+          add_action( 'pre_get_posts', array( $this, 'filter_post_types' ) );
81
+
82
+          add_filter( 'lsx_search_post_types', array( $this, 'register_post_types' ) );
83
+          add_filter( 'lsx_search_taxonomies', array( $this, 'register_taxonomies' ) );
84
+          add_filter( 'lsx_search_post_types_plural', array( $this, 'register_post_type_tabs' ) );
85
+          add_filter( 'facetwp_sort_options', array( $this, 'facetwp_sort_options' ), 10, 2 );
86
+          add_filter( 'wp_kses_allowed_html', array( $this, 'kses_allowed_html' ), 20, 2 );
87
+          add_filter( 'get_search_query', array( $this, 'get_search_query' ) );
88
+
89
+          // Redirects.
90
+          add_action( 'template_redirect', array( $this, 'pretty_search_redirect' ) );
91
+          add_filter( 'pre_get_posts', array( $this, 'pretty_search_parse_query' ) );
92
+
93
+          add_action( 'lsx_search_sidebar_top', array( $this, 'search_sidebar_top' ) );
94
+          add_filter( 'facetwp_facet_html', array( $this, 'search_facet_html' ), 10, 2 );
95
+     }
96
+
97
+     /**
98
+      * Return an instance of this class.
99
+      *
100
+      * @since 1.0.0
101
+      *
102
+      * @return    object \lsx\member_directory\search\Frontend()    A single instance of this class.
103
+      */
104
+     public static function get_instance() {
105
+          // If the single instance hasn't been set, set it now.
106
+          if ( null === self::$instance ) {
107
+               self::$instance = new self();
108
+          }
109
+          return self::$instance;
110
+     }
111
+
112
+     /**
113
+      * Loads the variable classes and the static classes.
114
+      */
115
+     private function load_classes() {
116
+          require_once LSX_SEARCH_PATH . 'classes/frontend/class-layout.php';
117
+          $this->layout = frontend\Layout::get_instance();
118
+     }
119
+
120
+     /**
121
+      * Check all settings.
122
+      */
123
+     public function set_vars() {
124
+          $post_type = '';
125
+
126
+          $this->post_types      = apply_filters( 'lsx_search_post_types', array() );
127
+          $this->taxonomies      = apply_filters( 'lsx_search_taxonomies', array() );
128
+          $this->tabs            = apply_filters( 'lsx_search_post_types_plural', array() );
129
+          $this->options         = apply_filters( 'lsx_search_options', $this->options );
130
+          $this->post_types      = get_post_types();
131
+          $this->post_type_slugs = array(
132
+               'post'        => 'posts',
133
+               'project'     => 'projects',
134
+               'service'     => 'services',
135
+               'team'        => 'team',
136
+               'testimonial' => 'testimonials',
137
+               'video'       => 'videos',
138
+               'product'     => 'products',
139
+          );
140
+          $this->set_search_prefix();
141
+          $this->get_cmb2_options();
142
+          $this->search_enabled = apply_filters( 'lsx_search_enabled', $this->is_search_enabled(), $this );
143
+          $this->search_prefix  = apply_filters( 'lsx_search_prefix', $this->search_prefix, $this );
144
+     }
145
+
146
+     private function get_cmb2_options() {
147
+          $cmb2_options = get_option( 'lsx-search-settings' );
148
+          if ( false !== $cmb2_options && ! empty( $cmb2_options ) ) {
149
+               $this->set_search_prefix( true );
150
+               $this->options['display'] = $cmb2_options;
151
+               foreach ( $this->options['display'] as $option_key => $option_value ) {
152
+                    if ( is_array( $option_value ) && ! empty( $option_value ) ) {
153
+                         $new_values = array();
154
+                         foreach ( $option_value as $empty_key => $key_value ) {
155
+                              $new_values[ $key_value ] = 'on';
156
+                         }
157
+                         $this->options['display'][ $option_key ] = $new_values;
158
+                    }
159
+               }
160
+               $this->new_options = true;
161
+               $this->disable_to_search_actions();
162
+          }
163
+     }
164
+
165
+     private function disable_to_search_actions() {
166
+          global $lsx_to_search_fwp, $lsx_to_search;
167
+          if ( null !== $lsx_to_search ) {
168
+               // Redirects.
169
+               remove_filter( 'template_include', array( $lsx_to_search, 'search_template_include' ), 99 );
170
+               remove_action( 'template_redirect', array( $lsx_to_search, 'pretty_search_redirect' ) );
171
+               remove_filter( 'pre_get_posts', array( $lsx_to_search, 'pretty_search_parse_query' ) );
172
+
173
+               // Layout Filter.
174
+               remove_filter( 'lsx_layout', array( $lsx_to_search, 'lsx_layout' ), 20, 1 );
175
+               remove_filter( 'lsx_layout_selector', array( $lsx_to_search, 'lsx_layout_selector' ), 10, 4 );
176
+               remove_filter( 'lsx_to_archive_layout', array( $lsx_to_search, 'lsx_to_search_archive_layout' ), 10, 2 );
177
+
178
+               remove_action( 'lsx_search_sidebar_top', array( $lsx_to_search, 'search_sidebar_top' ) );
179
+               remove_action( 'pre_get_posts', array( $lsx_to_search, 'price_sorting' ), 100 );
180
+
181
+               //add_shortcode( 'lsx_search_form', array( 'LSX_TO_Search_Frontend', 'search_form' ) );
182
+               remove_filter( 'searchwp_short_circuit', array( $lsx_to_search, 'searchwp_short_circuit' ), 10, 2 );
183
+               remove_filter( 'get_search_query', array( $lsx_to_search, 'get_search_query' ) );
184
+               remove_filter( 'body_class', array( $lsx_to_search, 'to_add_search_url_class' ), 20 );
185
+
186
+               remove_filter( 'facetwp_preload_url_vars', array( $lsx_to_search, 'preload_url_vars' ), 10, 1 );
187
+               remove_filter( 'wpseo_json_ld_search_url', array( $lsx_to_search, 'change_json_ld_search_url' ), 10, 1 );
188
+          }
189
+          if ( null !== $lsx_to_search_fwp ) {
190
+               remove_filter( 'facetwp_indexer_row_data', array( $lsx_to_search_fwp, 'facetwp_index_row_data' ), 10, 2 );
191
+               remove_filter( 'facetwp_index_row', array( $lsx_to_search_fwp, 'facetwp_index_row' ), 10, 2 );
192
+
193
+               remove_filter( 'facetwp_sort_options', array( $lsx_to_search_fwp, 'facet_sort_options' ), 10, 2 );
194
+
195
+               remove_filter( 'facetwp_pager_html', array( $lsx_to_search_fwp, 'facetwp_pager_html' ), 10, 2 );
196
+               remove_filter( 'facetwp_result_count', array( $lsx_to_search_fwp, 'facetwp_result_count' ), 10, 2 );
197
+
198
+               remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'destination_facet_html' ), 10, 2 );
199
+               remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'slide_facet_html' ), 10, 2 );
200
+               remove_filter( 'facetwp_facet_html', array( $lsx_to_search_fwp, 'search_facet_html' ), 10, 2 );
201
+               remove_filter( 'facetwp_load_css', array( $lsx_to_search_fwp, 'facetwp_load_css' ), 10, 1 );
202
+
203
+               if ( class_exists( 'LSX_Currencies' ) ) {
204
+                    remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_lsx_currencies' ), 10, 2 );
205
+               } else {
206
+                    remove_filter( 'facetwp_render_output', array( $lsx_to_search_fwp, 'slide_price_to_currencies' ), 10, 2 );
207
+               }
208
+          }
209
+     }
210
+
211
+     /**
212
+      * Returns if the search is enabled.
213
+      *
214
+      * @return boolean
215
+      */
216
+     public function is_search_enabled() {
217
+          $search_enabled = false;
218
+
219
+          if ( false === $this->new_options ) {
220
+               if ( isset( $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) && ( ! empty( $this->options ) ) && 'on' == $this->options['display'][ $this->search_prefix . '_enable_' . $this->search_core_suffix ] ) {
221
+                    $search_enabled = true;
222
+               }
223
+          } else {
224
+               $enable_prefix = $this->search_prefix;
225
+               if ( ! empty( $this->options ) && isset( $this->options['display'] ) && isset( $this->options['display'][ $enable_prefix . '_enable' ] ) && 'on' === $this->options['display'][ $enable_prefix . '_enable' ] ) {
226
+                    $search_enabled = true;
227
+               }
228
+          }
229
+
230
+          // These are specific plugin exclusions.
231
+          if ( is_tax( array( 'wcpv_product_vendors' ) ) ) {
232
+               $search_enabled = false;
233
+          }
234
+          return $search_enabled;
235
+     }
236
+
237
+     /**
238
+      * Sets the search prefix.
239
+      *
240
+      * @return void
241
+      */
242
+     private function set_search_prefix( $new_prefixes = false ) {
243
+          $page_for_posts = get_option( 'page_for_posts' );
244
+          if ( false !== $new_prefixes ) {
245
+               $this->taxonomies = array();
246
+               $this->post_types = array();
247
+          }
248
+
249
+          if ( is_search() ) {
250
+               if ( false === $new_prefixes ) {
251
+                    $this->search_core_suffix = 'core';
252
+                    $this->search_prefix      = 'search';
253
+               } else {
254
+                    $this->search_core_suffix = 'enable';
255
+                    $this->search_prefix      = 'engine_search';
256
+               }
257
+          } elseif ( is_post_type_archive( $this->post_types ) || is_tax() || is_page( $page_for_posts ) || is_home() || is_category() || is_tag() ) {
258
+               if ( false === $new_prefixes ) {
259
+                    $this->search_core_suffix = 'search';
260
+               } else {
261
+                    $this->search_core_suffix = 'enable';
262
+               }
263
+
264
+               if ( is_tax() ) {
265
+                    $tax = get_query_var( 'taxonomy' );
266
+                    $tax = get_taxonomy( $tax );
267
+                    $post_type = $tax->object_type[0];
268
+               } else if ( is_page( $page_for_posts ) || is_category() || is_tag() || is_home() ) {
269
+                    $post_type = 'post';
270
+               } else {
271
+                    $post_type = get_query_var( 'post_type' );
272
+               }
273
+
274
+               if ( false === $new_prefixes ) {
275
+                    if ( isset( $this->tabs[ $post_type ] ) ) {
276
+                         $this->search_prefix = $this->tabs[ $post_type ] . '_archive';
277
+                    }
278
+               } else {
279
+                    $this->search_prefix = $post_type . '_search';
280
+               }
281
+          }
282
+     }
283
+
284
+     /**
285
+      * Sets the FacetWP variables.
286
+      */
287
+     public function set_facetwp_vars() {
288
+
289
+          if ( class_exists( 'FacetWP' ) ) {
290
+               $facet_data = FWP()->helper->get_facets();
291
+          }
292
+
293
+          $this->facet_data = array();
294
+
295
+          $this->facet_data['search_form'] = array(
296
+               'name' => 'search_form',
297
+               'label' => esc_html__( 'Search Form', 'lsx-search' ),
298
+          );
299
+
300
+          if ( ! empty( $facet_data ) && is_array( $facet_data ) ) {
301
+               foreach ( $facet_data as $facet ) {
302
+                    $this->facet_data[ $facet['name'] ] = $facet;
303
+               }
304
+          }
305
+     }
306
+
307
+     /**
308
+      * Check all settings.
309
+      */
310
+     public function core() {
311
+
312
+          if ( true === $this->search_enabled ) {
313
+               add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 999 );
314
+
315
+               add_filter( 'lsx_layout', array( $this, 'lsx_layout' ), 20, 1 );
316
+               add_filter( 'lsx_layout_selector', array( $this, 'lsx_layout_selector' ), 10, 4 );
317
+               add_filter( 'lsx_slot_class', array( $this, 'change_slot_column_class' ) );
318
+               add_action( 'lsx_entry_top', array( $this, 'add_label_to_title' ) );
319
+               add_filter( 'body_class', array( $this, 'body_class' ), 10 );
320
+
321
+               add_filter( 'lsx_blog_customizer_top_of_blog_action', array( $this, 'top_of_blog_action' ), 10, 1 );
322
+               add_filter( 'lsx_blog_customizer_blog_description_class', array( $this, 'blog_description_class' ), 10, 1 );
323
+
324
+               if ( class_exists( 'LSX_Videos' ) ) {
325
+                    global $lsx_videos_frontend;
326
+                    remove_action( 'lsx_content_top', array( $lsx_videos_frontend, 'categories_tabs' ), 15 );
327
+               }
328
+
329
+               add_filter( 'lsx_paging_nav_disable', '__return_true' );
330
+               add_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) );
331
+               add_action( 'lsx_content_top', array( $this, 'facetwp_tempate_open' ) );
332
+               add_action( 'lsx_content_bottom', array( $this, 'facetwp_tempate_close' ) );
333
+               add_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) );
334
+
335
+               if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) && '1c' !== $this->options['display'][ $this->search_prefix . '_layout' ] ) {
336
+                    add_filter( 'lsx_sidebar_enable', array( $this, 'lsx_sidebar_enable' ), 10, 1 );
337
+               }
338
+
339
+               add_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 );
340
+
341
+               if ( class_exists( 'WooCommerce' ) && ( is_shop() || is_product_category() || is_product_tag() ) ) {
342
+                    remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
343
+                    remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' );
344
+                    add_filter( 'woocommerce_show_page_title', '__return_false' );
345
+
346
+                    add_filter( 'loop_shop_columns', function() {
347
+                         return 3;
348
+                    } );
349
+
350
+                    // Actions added by LSX theme
351
+                    remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
352
+                    add_action( 'lsx_content_wrap_before', array( $this, 'wc_archive_header' ), 140 );
353
+
354
+                    // Actions added be LSX theme / woocommerce.php file
355
+                    remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper', 9 );
356
+                    remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
357
+                    remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
358
+                    remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 );
359
+                    remove_action( 'woocommerce_after_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 );
360
+
361
+                    // Actions added be LSX theme / woocommerce.php file
362
+                    remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper', 9 );
363
+                    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
364
+                    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
365
+                    remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_woocommerce_pagination', 30 );
366
+                    remove_action( 'woocommerce_before_shop_loop', 'lsx_wc_sorting_wrapper_close', 31 );
367
+               }
368
+          }
369
+     }
370
+
371
+     /**
372
+      * Adds a search class to the body to allow the styling of the sidebars etc.
373
+      *
374
+      * @param  array $classes The classes.
375
+      * @return array $classes The classes.
376
+      */
377
+     public function body_class( $classes ) {
378
+          $classes[] = 'lsx-search-enabled';
379
+          return $classes;
380
+     }
381
+
382
+     /**
383
+      * Moves the blog description to above the content columns.
384
+      *
385
+      * @param  string $action
386
+      * @return string $action
387
+      */
388
+     public function top_of_blog_action( $action = '' ) {
389
+          $action = 'lsx_content_wrap_before';
390
+          return $action;
391
+     }
392
+
393
+     /**
394
+      * Adds a class to the blog description.
395
+      *
396
+      * @param  string $action
397
+      * @return string $action
398
+      */
399
+     public function blog_description_class( $class = '' ) {
400
+          $class .= ' col-md-12 search-description';
401
+          return $class;
402
+     }
403
+
404
+     /**
405
+      * Check the $wp_query global to see if there are posts in the current query.
406
+      *
407
+      * @return void
408
+      */
409
+     public function check_for_results() {
410
+          if ( true === $this->search_enabled ) {
411
+               global $wp_query;
412
+               if ( empty( $wp_query->posts ) ) {
413
+                    $this->has_posts = false;
414
+                    remove_action( 'lsx_content_top', array( $this, 'facet_top_bar' ) );
415
+                    remove_action( 'lsx_content_bottom', array( $this, 'facet_bottom_bar' ) );
416
+                    remove_action( 'lsx_content_wrap_before', array( $this, 'search_sidebar' ), 150 );
417
+               } else {
418
+                    $this->has_posts = true;
419
+               }
420
+          }
421
+     }
422
+
423
+     /**
424
+      * Filter the post types.
425
+      */
426
+     public function filter_post_types( $query ) {
427
+          if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
428
+               if ( ! empty( $this->options ) && ! empty( $this->options['display']['search_enable_core'] ) ) {
429
+                    if ( ! empty( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) {
430
+                         $post_types = array_keys( $this->options['general']['search_post_types'] );
431
+                         $query->set( 'post_type', $post_types );
432
+                    }
433
+               }
434
+          }
435
+     }
436
+
437
+     /**
438
+      * Sets post types with active search options.
439
+      */
440
+     public function register_post_types( $post_types ) {
441
+          $post_types = array( 'post', 'project', 'service', 'team', 'testimonial', 'video', 'product' );
442
+          return $post_types;
443
+     }
444
+
445
+     /**
446
+      * Sets taxonomies with active search options.
447
+      */
448
+     public function register_taxonomies( $taxonomies ) {
449
+          $taxonomies = array( 'category', 'post_tag', 'project-group', 'service-group', 'team_role', 'video-category', 'product_cat', 'product_tag' );
450
+          return $taxonomies;
451
+     }
452
+
453
+     /**
454
+      * Sets post types with active search options.
455
+      */
456
+     public function register_post_type_tabs( $post_types_plural ) {
457
+          $post_types_plural = array(
458
+               'post' => 'posts',
459
+               'project' => 'projects',
460
+               'service' => 'services',
461
+               'team' => 'team',
462
+               'testimonial' => 'testimonials',
463
+               'video' => 'videos',
464
+               'product' => 'products', // WooCommerce
465
+          );
466
+          return $post_types_plural;
467
+     }
468
+
469
+     /**
470
+      * Enqueue styles and scripts.
471
+      */
472
+     public function assets() {
473
+          add_filter( 'lsx_defer_parsing_of_js', array( $this, 'skip_js_defer' ), 10, 4 );
474
+          wp_enqueue_script( 'touchSwipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.touchSwipe.min.js', array( 'jquery' ), LSX_SEARCH_VER, true );
475
+          wp_enqueue_script( 'slideandswipe', LSX_SEARCH_URL . 'assets/js/vendor/jquery.slideandswipe.min.js', array( 'jquery', 'touchSwipe' ), LSX_SEARCH_VER, true );
476
+          wp_enqueue_script( 'lsx-search', LSX_SEARCH_URL . 'assets/js/src/lsx-search.js', array( 'jquery', 'touchSwipe', 'slideandswipe', 'jquery-ui-datepicker' ), LSX_SEARCH_VER, true );
477
+
478
+          $params = apply_filters( 'lsx_search_js_params', array(
479
+               'ajax_url' => admin_url( 'admin-ajax.php' ),
480
+          ));
481
+
482
+          wp_localize_script( 'lsx-search', 'lsx_customizer_params', $params );
483
+
484
+          wp_enqueue_style( 'lsx-search', LSX_SEARCH_URL . 'assets/css/lsx-search.css', array(), LSX_SEARCH_VER );
485
+          wp_style_add_data( 'lsx-search', 'rtl', 'replace' );
486
+
487
+          if ( true === $this->new_options ) {
488
+               wp_deregister_style( 'lsx_to_search' );
489
+               wp_deregister_script( 'lsx_to_search' );
490
+          }
491
+     }
492
+
493
+     /**
494
+      * Adds the to-search.min.js and the to-search.js
495
+      *
496
+      * @param boolean $should_skip
497
+      * @param string  $tag
498
+      * @param string  $handle
499
+      * @param string  $href
500
+      * @return boolean
501
+      */
502
+     public function skip_js_defer( $should_skip, $tag, $handle, $href ) {
503
+          if ( ! is_admin() && ( false !== stripos( $href, 'lsx-search.min.js' ) || false !== stripos( $href, 'lsx-search.js' ) ) ) {
504
+               $should_skip = true;
505
+          }
506
+          return $should_skip;
507
+     }
508
+
509
+     /**
510
+      * Redirect wordpress to the search template located in the plugin
511
+      *
512
+      * @param	$template
513
+      * @return	$template
514
+      */
515
+     public function search_template_include( $template ) {
516
+          if ( is_main_query() && is_search() ) {
517
+               if ( file_exists( LSX_SEARCH_PATH . 'templates/search.php' ) ) {
518
+                    $template = LSX_SEARCH_PATH . 'templates/search.php';
519
+               }
520
+          }
521
+
522
+          return $template;
523
+     }
524
+
525
+     /**
526
+      * Ignore sticky posts on Blog search.
527
+      *
528
+      * @param [type] $query
529
+      * @return void
530
+      */
531
+     public function ignore_sticky_search( $query ) {
532
+          if ( $query->is_main_query() && is_home() ) {
533
+               $query->set( 'ignore_sticky_posts', true );
534
+          }
535
+     }
536
+
537
+     /**
538
+      * Rewrite the search URL
539
+      */
540
+     public function pretty_search_redirect() {
541
+          global $wp_rewrite,$wp_query;
542
+
543
+          if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) {
544
+               return;
545
+          }
546
+
547
+          $search_base = $wp_rewrite->search_base;
548
+
549
+          if ( is_search() && ! is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) {
550
+               $search_query = get_query_var( 's' );
551
+               if ( empty( $search_query ) && isset( $_GET['s'] ) ) {
552
+                    $search_query = $_GET['s'];
553
+               }
554
+               $engine = '';
555
+
556
+               // If the search was triggered by a supplemental engine.
557
+               if ( isset( $_GET['engine'] ) && 'default' !== $_GET['engine'] ) {
558
+                    $engine = sanitize_text_field( wp_unslash( $_GET['engine'] ) );
559
+                    $index  = array_search( $engine, $this->post_type_slugs, true );
560
+                    if ( false !== $index ) {
561
+                         $engine = $index;
562
+                    }
563
+                    $engine = $engine . '/';
564
+               }
565
+
566
+               $get_array = $_GET;
567
+
568
+               if ( is_array( $get_array ) && ! empty( $get_array ) ) {
569
+                    $vars_to_maintain = array();
570
+
571
+                    foreach ( $get_array as $ga_key => $ga_value ) {
572
+                         if ( false !== strpos( $ga_key, 'fwp_' ) ) {
573
+                              $vars_to_maintain[] = $ga_key . '=' . $ga_value;
574
+                         }
575
+                    }
576
+               }
577
+
578
+               $redirect_url = home_url( "/{$search_base}/" . $engine . urlencode( $search_query ) );
579
+
580
+               if ( ! empty( $vars_to_maintain ) ) {
581
+                    $redirect_url .= '?' . implode( '&', $vars_to_maintain );
582
+               }
583
+               wp_redirect( $redirect_url );
584
+               exit();
585
+          }
586
+     }
587
+
588
+     /**
589
+      * Parse the Query and trigger a search
590
+      */
591
+     public function pretty_search_parse_query( $query ) {
592
+          $this->post_type_slugs = array(
593
+               'post' => 'posts',
594
+               'project' => 'projects',
595
+               'service' => 'services',
596
+               'team' => 'team',
597
+               'testimonial' => 'testimonials',
598
+               'video' => 'videos',
599
+               'product' => 'products', // WooCommerce
600
+          );
601
+          if ( $query->is_search() && ! is_admin() && $query->is_main_query() ) {
602
+               $search_query = $query->get( 's' );
603
+               $keyword_test = explode( '/', $search_query );
604
+
605
+               $index = array_search( $keyword_test[0], $this->post_type_slugs, true );
606
+               if ( false !== $index ) {
607
+                    $engine = $this->post_type_slugs[ $index ];
608
+
609
+                    $query->set( 'post_type', $engine );
610
+                    $query->set( 'engine', $engine );
611
+
612
+                    if ( count( $keyword_test ) > 1 ) {
613
+                         $query->set( 's', $keyword_test[1] );
614
+                    } elseif ( post_type_exists( $engine ) ) {
615
+                         $query->set( 's', '' );
616
+                    }
617
+               } else {
618
+                    if ( isset( $this->options['general']['search_post_types'] ) && is_array( $this->options['general']['search_post_types'] ) ) {
619
+                         $post_types = array_keys( $this->options['general']['search_post_types'] );
620
+                         $query->set( 'post_type', $post_types );
621
+                    }
622
+               }
623
+          }
624
+          return $query;
625
+     }
626
+
627
+     /**
628
+      * Change the search slug to /search/ for the JSON+LD output in Yoast SEO
629
+      *
630
+      * @return url
631
+      */
632
+     public function change_json_ld_search_url() {
633
+          return trailingslashit( home_url() ) . 'search/{search_term_string}';
634
+     }
635
+
636
+     /**
637
+      * A filter to set the layout to 2 column.
638
+      */
639
+     public function lsx_layout( $layout ) {
640
+          if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) {
641
+               if ( false === $this->has_posts ) {
642
+                    $layout = '1c';
643
+               } else {
644
+                    $layout = $this->options['display'][ $this->search_prefix . '_layout' ];
645
+               }
646
+          }
647
+          return $layout;
648
+     }
649
+
650
+     /**
651
+      * Outputs the Search Title Facet
652
+      */
653
+     public function search_sidebar_top() {
654
+          if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) && true !== apply_filters( 'lsx_search_hide_search_box', false ) ) {
655
+
656
+               if ( ! is_search() ) {
657
+
658
+                    foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) {
659
+
660
+                         if ( isset( $this->facet_data[ $facet ] ) && 'search' === $this->facet_data[ $facet ]['type'] ) {
661
+                              echo wp_kses_post( '<div class="row">' );
662
+                                   $this->display_facet_default( $facet );
663
+                              echo wp_kses_post( '</div>' );
664
+                              unset( $this->options['display'][ $this->search_prefix . '_facets' ][ $facet ] );
665
+                         }
666
+                    }
667
+               } else {
668
+                    echo wp_kses_post( '<div class="row">' );
669
+                         $this->display_facet_search();
670
+                    echo wp_kses_post( '</div>' );
671
+               }
672
+          }
673
+     }
674
+
675
+     /**
676
+      * Overrides the search facet HTML
677
+      * @param $output
678
+      * @param $params
679
+      *
680
+      * @return string
681
+      */
682
+     public function search_facet_html( $output, $params ) {
683
+          if ( 'search' == $params['facet']['type'] ) {
684
+
685
+               $value = (array) $params['selected_values'];
686
+               $value = empty( $value ) ? '' : stripslashes( $value[0] );
687
+               $placeholder = isset( $params['facet']['placeholder'] ) ? $params['facet']['placeholder'] : __( 'Search...', 'lsx-search' );
688
+               $placeholder = facetwp_i18n( $placeholder );
689
+
690
+               ob_start();
691
+               ?>
692 692
 			<div class="col-xs-12 facetwp-item facetwp-form">
693 693
 				<div class="search-form lsx-search-form 2">
694 694
 					<div class="input-group facetwp-search-wrap">
@@ -703,75 +703,75 @@  discard block
 block discarded – undo
703 703
 				</div>
704 704
 			</div>
705 705
 			<?php
706
-			$output = ob_get_clean();
707
-		}
708
-		return $output;
709
-	}
710
-
711
-	/**
712
-	 * Change the primary and secondary column classes.
713
-	 */
714
-	public function lsx_layout_selector( $return_class, $class, $layout, $size ) {
715
-		if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) {
716
-
717
-			if ( '2cl' === $layout || '2cr' === $layout ) {
718
-				$main_class    = 'col-sm-8 col-md-9';
719
-				$sidebar_class = 'col-sm-4 col-md-3';
720
-
721
-				if ( '2cl' === $layout ) {
722
-					$main_class    .= ' col-sm-pull-4 col-md-pull-3 search-sidebar-left';
723
-					$sidebar_class .= ' col-sm-push-8 col-md-push-9';
724
-				}
725
-
726
-				if ( 'main' === $class ) {
727
-					return $main_class;
728
-				}
729
-
730
-				if ( 'sidebar' === $class ) {
731
-					return $sidebar_class;
732
-				}
733
-			}
734
-		}
735
-
736
-		return $return_class;
737
-	}
738
-
739
-	/**
740
-	 * Displays the Alphabet sorter above the facets.
741
-	 *
742
-	 * @return void
743
-	 */
744
-	public function display_alphabet_facet() {
745
-		if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) {
746
-			$az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ];
747
-		} else {
748
-			$az_pagination = false;
749
-		}
750
-		$az_pagination = apply_filters( 'lsx_search_top_az_pagination', $az_pagination );
751
-		if ( false !== $az_pagination && '' !== $az_pagination ) {
752
-			echo do_shortcode( '[facetwp facet="' . $az_pagination . '"]' );
753
-		}
754
-	}
755
-
756
-	/**
757
-	 * Outputs top.
758
-	 */
759
-	public function facet_top_bar() {
760
-		if ( true === apply_filters( 'lsx_search_hide_top_bar', false ) ) {
761
-			return;
762
-		}
763
-
764
-		$show_pagination     = true;
765
-		$pagination_visible  = false;
766
-		$show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] );
767
-		$show_sort_combo     = empty( $this->options['display'][ $this->search_prefix . '_disable_sorting' ] );
768
-
769
-		$show_pagination     = apply_filters( 'lsx_search_top_show_pagination', $show_pagination );
770
-		$pagination_visible  = apply_filters( 'lsx_search_top_pagination_visible', $pagination_visible );
771
-		$show_per_page_combo = apply_filters( 'lsx_search_top_show_per_page_combo', $show_per_page_combo );
772
-		$show_sort_combo     = apply_filters( 'lsx_search_top_show_sort_combo', $show_sort_combo );
773
-		$facet_row_classes   = apply_filters( 'lsx_search_top_facetwp_row_classes', '' );
774
-		?>
706
+               $output = ob_get_clean();
707
+          }
708
+          return $output;
709
+     }
710
+
711
+     /**
712
+      * Change the primary and secondary column classes.
713
+      */
714
+     public function lsx_layout_selector( $return_class, $class, $layout, $size ) {
715
+          if ( ! empty( $this->options['display'][ $this->search_prefix . '_layout' ] ) ) {
716
+
717
+               if ( '2cl' === $layout || '2cr' === $layout ) {
718
+                    $main_class    = 'col-sm-8 col-md-9';
719
+                    $sidebar_class = 'col-sm-4 col-md-3';
720
+
721
+                    if ( '2cl' === $layout ) {
722
+                         $main_class    .= ' col-sm-pull-4 col-md-pull-3 search-sidebar-left';
723
+                         $sidebar_class .= ' col-sm-push-8 col-md-push-9';
724
+                    }
725
+
726
+                    if ( 'main' === $class ) {
727
+                         return $main_class;
728
+                    }
729
+
730
+                    if ( 'sidebar' === $class ) {
731
+                         return $sidebar_class;
732
+                    }
733
+               }
734
+          }
735
+
736
+          return $return_class;
737
+     }
738
+
739
+     /**
740
+      * Displays the Alphabet sorter above the facets.
741
+      *
742
+      * @return void
743
+      */
744
+     public function display_alphabet_facet() {
745
+          if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) {
746
+               $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ];
747
+          } else {
748
+               $az_pagination = false;
749
+          }
750
+          $az_pagination = apply_filters( 'lsx_search_top_az_pagination', $az_pagination );
751
+          if ( false !== $az_pagination && '' !== $az_pagination ) {
752
+               echo do_shortcode( '[facetwp facet="' . $az_pagination . '"]' );
753
+          }
754
+     }
755
+
756
+     /**
757
+      * Outputs top.
758
+      */
759
+     public function facet_top_bar() {
760
+          if ( true === apply_filters( 'lsx_search_hide_top_bar', false ) ) {
761
+               return;
762
+          }
763
+
764
+          $show_pagination     = true;
765
+          $pagination_visible  = false;
766
+          $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] );
767
+          $show_sort_combo     = empty( $this->options['display'][ $this->search_prefix . '_disable_sorting' ] );
768
+
769
+          $show_pagination     = apply_filters( 'lsx_search_top_show_pagination', $show_pagination );
770
+          $pagination_visible  = apply_filters( 'lsx_search_top_pagination_visible', $pagination_visible );
771
+          $show_per_page_combo = apply_filters( 'lsx_search_top_show_per_page_combo', $show_per_page_combo );
772
+          $show_sort_combo     = apply_filters( 'lsx_search_top_show_sort_combo', $show_sort_combo );
773
+          $facet_row_classes   = apply_filters( 'lsx_search_top_facetwp_row_classes', '' );
774
+          ?>
775 775
 		<div id="facetwp-top">
776 776
 			<?php if ( $show_sort_combo || ( $show_pagination && $show_per_page_combo ) ) { ?>
777 777
 				<div class="row facetwp-top-row-1 hidden-xs <?php echo esc_attr( $facet_row_classes ); ?>">
@@ -802,32 +802,32 @@  discard block
 block discarded – undo
802 802
 			<?php } ?>
803 803
 		</div>
804 804
 		<?php
805
-	}
806
-
807
-	/**
808
-	 * Outputs bottom.
809
-	 */
810
-	public function facet_bottom_bar() {
811
-		if ( true === apply_filters( 'lsx_search_hide_bottom_bar', false ) ) {
812
-			return;
813
-		}
814
-		$show_pagination    = true;
815
-		$pagination_visible = false;
816
-		if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) {
817
-			$az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ];
818
-		} else {
819
-			$az_pagination = false;
820
-		}
821
-
822
-		$show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] );
823
-		$show_sort_combo     = empty( $this->options['display'][ $this->search_prefix . '_search_disable_sorting' ] );
824
-
825
-		$show_pagination     = apply_filters( 'lsx_search_bottom_show_pagination', $show_pagination );
826
-		$pagination_visible  = apply_filters( 'lsx_search_bottom_pagination_visible', $pagination_visible );
827
-		$show_per_page_combo = apply_filters( 'lsx_search_bottom_show_per_page_combo', $show_per_page_combo );
828
-		$show_sort_combo     = apply_filters( 'lsx_search_bottom_show_sort_combo', $show_sort_combo );
829
-
830
-		if ( $show_pagination || ! empty( $az_pagination ) ) { ?>
805
+     }
806
+
807
+     /**
808
+      * Outputs bottom.
809
+      */
810
+     public function facet_bottom_bar() {
811
+          if ( true === apply_filters( 'lsx_search_hide_bottom_bar', false ) ) {
812
+               return;
813
+          }
814
+          $show_pagination    = true;
815
+          $pagination_visible = false;
816
+          if ( isset( $this->options['display'][ $this->search_prefix . '_az_pagination' ] ) ) {
817
+               $az_pagination = $this->options['display'][ $this->search_prefix . '_az_pagination' ];
818
+          } else {
819
+               $az_pagination = false;
820
+          }
821
+
822
+          $show_per_page_combo = empty( $this->options['display'][ $this->search_prefix . '_disable_per_page' ] );
823
+          $show_sort_combo     = empty( $this->options['display'][ $this->search_prefix . '_search_disable_sorting' ] );
824
+
825
+          $show_pagination     = apply_filters( 'lsx_search_bottom_show_pagination', $show_pagination );
826
+          $pagination_visible  = apply_filters( 'lsx_search_bottom_pagination_visible', $pagination_visible );
827
+          $show_per_page_combo = apply_filters( 'lsx_search_bottom_show_per_page_combo', $show_per_page_combo );
828
+          $show_sort_combo     = apply_filters( 'lsx_search_bottom_show_sort_combo', $show_sort_combo );
829
+
830
+          if ( $show_pagination || ! empty( $az_pagination ) ) { ?>
831 831
 			<div id="facetwp-bottom">
832 832
 				<div class="row facetwp-bottom-row-1">
833 833
 					<div class="col-xs-12">
@@ -842,61 +842,61 @@  discard block
 block discarded – undo
842 842
 						<?php //} ?>
843 843
 
844 844
 						<?php
845
-						if ( $show_pagination ) {
846
-							$output_pagination = do_shortcode( '[facetwp pager="true"]' );
847
-							if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) {
848
-								foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) {
849
-									if ( isset( $this->facet_data[ $facet ] ) && in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) {
850
-										$output_pagination = do_shortcode( '[facetwp facet="pager_"]' );
851
-									}
852
-								}
853
-							}
854
-							echo wp_kses_post( $output_pagination );
855
-						?>
845
+                              if ( $show_pagination ) {
846
+                                   $output_pagination = do_shortcode( '[facetwp pager="true"]' );
847
+                                   if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) {
848
+                                        foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) {
849
+                                             if ( isset( $this->facet_data[ $facet ] ) && in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) {
850
+                                                  $output_pagination = do_shortcode( '[facetwp facet="pager_"]' );
851
+                                             }
852
+                                        }
853
+                                   }
854
+                                   echo wp_kses_post( $output_pagination );
855
+                              ?>
856 856
 						<?php } ?>
857 857
 					</div>
858 858
 				</div>
859 859
 			</div>
860 860
 		<?php }
861
-	}
862
-
863
-	/**
864
-	 * Adds in the closing facetwp div
865
-	 *
866
-	 * @return void
867
-	 */
868
-	public function facetwp_tempate_open() {
869
-		?>
861
+     }
862
+
863
+     /**
864
+      * Adds in the closing facetwp div
865
+      *
866
+      * @return void
867
+      */
868
+     public function facetwp_tempate_open() {
869
+          ?>
870 870
 		<div class="facetwp-template">
871 871
 		<?php
872
-	}
873
-
874
-	/**
875
-	 * Adds in the closing facetwp div
876
-	 *
877
-	 * @return void
878
-	 */
879
-	public function facetwp_tempate_close() {
880
-		?>
872
+     }
873
+
874
+     /**
875
+      * Adds in the closing facetwp div
876
+      *
877
+      * @return void
878
+      */
879
+     public function facetwp_tempate_close() {
880
+          ?>
881 881
 		</div>
882 882
 		<?php
883
-	}
884
-
885
-	/**
886
-	 * Disables default sidebar.
887
-	 */
888
-	public function lsx_sidebar_enable( $sidebar_enabled ) {
889
-		$sidebar_enabled = false;
890
-		return $sidebar_enabled;
891
-	}
892
-
893
-	/**
894
-	 * Outputs custom sidebar.
895
-	 */
896
-	public function search_sidebar() {
897
-
898
-		$this->options = apply_filters( 'lsx_search_sidebar_options', $this->options );
899
-		?>
883
+     }
884
+
885
+     /**
886
+      * Disables default sidebar.
887
+      */
888
+     public function lsx_sidebar_enable( $sidebar_enabled ) {
889
+          $sidebar_enabled = false;
890
+          return $sidebar_enabled;
891
+     }
892
+
893
+     /**
894
+      * Outputs custom sidebar.
895
+      */
896
+     public function search_sidebar() {
897
+
898
+          $this->options = apply_filters( 'lsx_search_sidebar_options', $this->options );
899
+          ?>
900 900
 			<?php do_action( 'lsx_search_sidebar_before' ); ?>
901 901
 
902 902
 			<div id="secondary" class="facetwp-sidebar widget-area <?php echo esc_attr( lsx_sidebar_class() ); ?>" role="complementary">
@@ -921,13 +921,13 @@  discard block
 block discarded – undo
921 921
 
922 922
 							<div class="row">
923 923
 								<?php
924
-								// Slider.
925
-								foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) {
926
-									if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'alpha', 'search', 'pager' ) ) ) {
927
-										$this->display_facet_default( $facet );
928
-									}
929
-								}
930
-								?>
924
+                                        // Slider.
925
+                                        foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) {
926
+                                             if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'alpha', 'search', 'pager' ) ) ) {
927
+                                                  $this->display_facet_default( $facet );
928
+                                             }
929
+                                        }
930
+                                        ?>
931 931
 							</div>
932 932
 
933 933
 							<div class="row hidden-sm hidden-md hidden-lg ssm-row-margin-top">
@@ -944,35 +944,35 @@  discard block
 block discarded – undo
944 944
 
945 945
 			<?php do_action( 'lsx_search_sidebar_after' ); ?>
946 946
 		<?php
947
-	}
948
-
949
-	/**
950
-	 * Check if the pager facet is on
951
-	 *
952
-	 * @return void
953
-	 */
954
-	public function pager_facet_enabled() {
955
-
956
-		$pager_facet_off = false;
957
-
958
-		if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) {
959
-			foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) {
960
-				if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) {
961
-					$pager_facet_off = true;
962
-				}
963
-			}
964
-		}
965
-
966
-		return $pager_facet_off;
967
-	}
968
-
969
-	/**
970
-	 * Display WooCommerce archive title.
971
-	 */
972
-	public function wc_archive_header() {
973
-		$default_size   = 'sm';
974
-		$size           = apply_filters( 'lsx_bootstrap_column_size', $default_size );
975
-		?>
947
+     }
948
+
949
+     /**
950
+      * Check if the pager facet is on
951
+      *
952
+      * @return void
953
+      */
954
+     public function pager_facet_enabled() {
955
+
956
+          $pager_facet_off = false;
957
+
958
+          if ( ! empty( $this->options['display'][ $this->search_prefix . '_facets' ] ) && is_array( $this->options['display'][ $this->search_prefix . '_facets' ] ) ) {
959
+               foreach ( $this->options['display'][ $this->search_prefix . '_facets' ] as $facet => $facet_useless ) {
960
+                    if ( isset( $this->facet_data[ $facet ] ) && ! in_array( $this->facet_data[ $facet ]['type'], array( 'pager' ) ) ) {
961
+                         $pager_facet_off = true;
962
+                    }
963
+               }
964
+          }
965
+
966
+          return $pager_facet_off;
967
+     }
968
+
969
+     /**
970
+      * Display WooCommerce archive title.
971
+      */
972
+     public function wc_archive_header() {
973
+          $default_size   = 'sm';
974
+          $size           = apply_filters( 'lsx_bootstrap_column_size', $default_size );
975
+          ?>
976 976
 			<div class="archive-header-wrapper banner-woocommerce col-<?php echo esc_attr( $size ); ?>-12">
977 977
 				<?php lsx_global_header_inner_bottom(); ?>
978 978
 				<header class="archive-header">
@@ -980,13 +980,13 @@  discard block
 block discarded – undo
980 980
 				</header>
981 981
 			</div>
982 982
 		<?php
983
-	}
983
+     }
984 984
 
985
-	/**
986
-	 * Display facet search.
987
-	 */
988
-	public function display_facet_search() {
989
-		?>
985
+     /**
986
+      * Display facet search.
987
+      */
988
+     public function display_facet_search() {
989
+          ?>
990 990
 		<div class="col-xs-12 facetwp-item facetwp-form">
991 991
 			<form class="search-form lsx-search-form" action="<?php echo esc_attr( home_url() ); ?>" method="get">
992 992
 				<div class="input-group">
@@ -1001,17 +1001,17 @@  discard block
 block discarded – undo
1001 1001
 			</form>
1002 1002
 		</div>
1003 1003
 		<?php
1004
-	}
1004
+     }
1005 1005
 
1006
-	/**
1007
-	 * Display facet default.
1008
-	 */
1009
-	public function display_facet_default( $facet ) {
1006
+     /**
1007
+      * Display facet default.
1008
+      */
1009
+     public function display_facet_default( $facet ) {
1010 1010
 
1011
-		$show_collapse = ! isset( $this->options['display'][$this->search_prefix . '_collapse'] ) || 'on' !== $this->options['display'][$this->search_prefix . '_collapse'];
1012
-		$col_class = '';
1011
+          $show_collapse = ! isset( $this->options['display'][$this->search_prefix . '_collapse'] ) || 'on' !== $this->options['display'][$this->search_prefix . '_collapse'];
1012
+          $col_class = '';
1013 1013
 
1014
-		if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?>
1014
+          if ( 'search' === $this->facet_data[ $facet ]['type'] ) : ?>
1015 1015
 			<?php echo do_shortcode( '[facetwp facet="' . $facet . '"]' ); ?>
1016 1016
 		<?php else : ?>
1017 1017
 			<div class="col-xs-12 facetwp-item parent-facetwp-facet-<?php echo esc_html( $facet ); ?> <?php echo esc_attr( $col_class ); ?>">
@@ -1029,101 +1029,101 @@  discard block
 block discarded – undo
1029 1029
 				<?php } ?>
1030 1030
 			</div>
1031 1031
 		<?php
1032
-		endif;
1033
-	}
1034
-
1035
-	/**
1036
-	 * Changes slot column class.
1037
-	 */
1038
-	public function change_slot_column_class( $class ) {
1039
-		if ( is_post_type_archive( 'video' ) || is_tax( 'video-category' ) ) {
1040
-			$column_class = 'col-xs-12 col-sm-4';
1041
-		}
1042
-
1043
-		return $column_class;
1044
-	}
1045
-
1046
-	/**
1047
-	 * Add post type label to the title.
1048
-	 */
1049
-	public function add_label_to_title() {
1050
-		if ( is_search() ) {
1051
-			if ( ! empty( $this->options['display']['engine_search_enable_pt_label'] ) ) {
1052
-				$post_type = get_post_type();
1053
-				$post_type = str_replace( '_', ' ', $post_type );
1054
-				$post_type = str_replace( '-', ' ', $post_type );
1055
-				if ( 'tribe events' === $post_type ) {
1056
-					$post_type = 'Events';
1057
-				}
1058
-				echo wp_kses_post( ' <span class="label label-default lsx-label-post-type">' . $post_type . '</span>' );
1059
-			}
1060
-		}
1061
-	}
1062
-
1063
-	/**
1064
-	 * Changes the sort options.
1065
-	 */
1066
-	public function facetwp_sort_options( $options, $params ) {
1067
-		$this->set_vars();
1068
-
1069
-		if ( true === $this->search_enabled ) {
1070
-			if ( 'default' !== $params['template_name'] && 'wp' !== $params['template_name'] ) {
1071
-				return $options;
1072
-			}
1073
-
1074
-			if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_date' ] ) ) {
1075
-				unset( $options['date_desc'] );
1076
-				unset( $options['date_asc'] );
1077
-			}
1078
-
1079
-			if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_az_sorting' ] ) ) {
1080
-				unset( $options['title_desc'] );
1081
-				unset( $options['title_asc'] );
1082
-			}
1083
-		}
1084
-
1085
-		return $options;
1086
-	}
1087
-
1088
-	/**
1089
-	 * @param $allowedtags
1090
-	 * @param $context
1091
-	 *
1092
-	 * @return mixed
1093
-	 */
1094
-	public function kses_allowed_html( $allowedtags, $context ) {
1095
-		$allowedtags['a']['data-value'] = true;
1096
-		$allowedtags['a']['data-selection']  = true;
1097
-		$allowedtags['button']['data-toggle'] = true;
1098
-		return $allowedtags;
1099
-	}
1100
-
1101
-	/**
1102
-	 * Change FaceWP result count HTML
1103
-	 */
1104
-	public function get_search_query( $keyword ) {
1105
-		global $wp_rewrite,$wp_query;
1106
-
1107
-		if ( empty( $keyword ) ) {
1108
-			if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) {
1109
-				return;
1110
-			}
1111
-			$search_base = $wp_rewrite->search_base;
1112
-			if ( strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) !== false ) {
1113
-				$words = explode( "/{$search_base}/", $_SERVER['REQUEST_URI'] );
1114
-				$limit = count( $words );
1115
-				if ( isset( $words[ $limit - 1 ] ) ) {
1116
-					$keyword = $words[ $limit - 1 ];
1117
-				}
1118
-			}
1119
-		}
1120
-
1121
-		$needle = trim( '/ ' );
1122
-		$words = explode( $needle, $keyword );
1123
-		if ( is_array( $words ) && ! empty( $words ) ) {
1124
-			$keyword = $words[ count( $words ) - 1 ];
1125
-		}
1126
-		$keyword = str_replace( '+', ' ', $keyword );
1127
-		return $keyword;
1128
-	}
1032
+          endif;
1033
+     }
1034
+
1035
+     /**
1036
+      * Changes slot column class.
1037
+      */
1038
+     public function change_slot_column_class( $class ) {
1039
+          if ( is_post_type_archive( 'video' ) || is_tax( 'video-category' ) ) {
1040
+               $column_class = 'col-xs-12 col-sm-4';
1041
+          }
1042
+
1043
+          return $column_class;
1044
+     }
1045
+
1046
+     /**
1047
+      * Add post type label to the title.
1048
+      */
1049
+     public function add_label_to_title() {
1050
+          if ( is_search() ) {
1051
+               if ( ! empty( $this->options['display']['engine_search_enable_pt_label'] ) ) {
1052
+                    $post_type = get_post_type();
1053
+                    $post_type = str_replace( '_', ' ', $post_type );
1054
+                    $post_type = str_replace( '-', ' ', $post_type );
1055
+                    if ( 'tribe events' === $post_type ) {
1056
+                         $post_type = 'Events';
1057
+                    }
1058
+                    echo wp_kses_post( ' <span class="label label-default lsx-label-post-type">' . $post_type . '</span>' );
1059
+               }
1060
+          }
1061
+     }
1062
+
1063
+     /**
1064
+      * Changes the sort options.
1065
+      */
1066
+     public function facetwp_sort_options( $options, $params ) {
1067
+          $this->set_vars();
1068
+
1069
+          if ( true === $this->search_enabled ) {
1070
+               if ( 'default' !== $params['template_name'] && 'wp' !== $params['template_name'] ) {
1071
+                    return $options;
1072
+               }
1073
+
1074
+               if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_date' ] ) ) {
1075
+                    unset( $options['date_desc'] );
1076
+                    unset( $options['date_asc'] );
1077
+               }
1078
+
1079
+               if ( ! empty( $this->options['display'][ $this->search_prefix . '_disable_az_sorting' ] ) ) {
1080
+                    unset( $options['title_desc'] );
1081
+                    unset( $options['title_asc'] );
1082
+               }
1083
+          }
1084
+
1085
+          return $options;
1086
+     }
1087
+
1088
+     /**
1089
+      * @param $allowedtags
1090
+      * @param $context
1091
+      *
1092
+      * @return mixed
1093
+      */
1094
+     public function kses_allowed_html( $allowedtags, $context ) {
1095
+          $allowedtags['a']['data-value'] = true;
1096
+          $allowedtags['a']['data-selection']  = true;
1097
+          $allowedtags['button']['data-toggle'] = true;
1098
+          return $allowedtags;
1099
+     }
1100
+
1101
+     /**
1102
+      * Change FaceWP result count HTML
1103
+      */
1104
+     public function get_search_query( $keyword ) {
1105
+          global $wp_rewrite,$wp_query;
1106
+
1107
+          if ( empty( $keyword ) ) {
1108
+               if ( ! isset( $wp_rewrite ) || ! is_object( $wp_rewrite ) || ! $wp_rewrite->using_permalinks() ) {
1109
+                    return;
1110
+               }
1111
+               $search_base = $wp_rewrite->search_base;
1112
+               if ( strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) !== false ) {
1113
+                    $words = explode( "/{$search_base}/", $_SERVER['REQUEST_URI'] );
1114
+                    $limit = count( $words );
1115
+                    if ( isset( $words[ $limit - 1 ] ) ) {
1116
+                         $keyword = $words[ $limit - 1 ];
1117
+                    }
1118
+               }
1119
+          }
1120
+
1121
+          $needle = trim( '/ ' );
1122
+          $words = explode( $needle, $keyword );
1123
+          if ( is_array( $words ) && ! empty( $words ) ) {
1124
+               $keyword = $words[ count( $words ) - 1 ];
1125
+          }
1126
+          $keyword = str_replace( '+', ' ', $keyword );
1127
+          return $keyword;
1128
+     }
1129 1129
 }
Please login to merge, or discard this patch.