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