| 1 | <?php |
|---|
| 2 | namespace Elementor; |
|---|
| 3 | |
|---|
| 4 | if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|---|
| 5 | |
|---|
| 6 | class Woolentor_Wl_Product_Horizontal_Filter_Widget extends Widget_Base { |
|---|
| 7 | |
|---|
| 8 | public function get_name() { |
|---|
| 9 | return 'wl-product-horizontal-filter'; |
|---|
| 10 | } |
|---|
| 11 | |
|---|
| 12 | public function get_title() { |
|---|
| 13 | return __( 'WL: Product Horizontal Filter', 'woolentor' ); |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | public function get_icon() { |
|---|
| 17 | return 'eicon-filter'; |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | public function get_categories() { |
|---|
| 21 | return ['woolentor-addons']; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | public function get_help_url() { |
|---|
| 25 | return 'https://woolentor.com/documentation/'; |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | public function get_style_depends(){ |
|---|
| 29 | return ['elementor-icons-shared-0-css','elementor-icons-fa-brands','elementor-icons-fa-regular','elementor-icons-fa-solid','woolentor-select2','woolentor-widgets']; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | public function get_script_depends() { |
|---|
| 33 | return ['select2-min']; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | public function get_keywords(){ |
|---|
| 37 | return ['woolentor','shop','filter','product filter','horizontal']; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | protected function register_controls() { |
|---|
| 41 | |
|---|
| 42 | $filter_by = [ |
|---|
| 43 | 'price_by' => esc_html__( 'Price', 'woolentor' ), |
|---|
| 44 | 'sort_by' => esc_html__( 'Sort By', 'woolentor' ), |
|---|
| 45 | 'order_by' => esc_html__( 'Order By', 'woolentor' ) |
|---|
| 46 | ]; |
|---|
| 47 | $prices = function_exists('woolentor_minmax_price_limit') ? woolentor_minmax_price_limit() : array('min' => 10,'max' => 20); |
|---|
| 48 | |
|---|
| 49 | $this->start_controls_section( |
|---|
| 50 | 'section_content', |
|---|
| 51 | [ |
|---|
| 52 | 'label' => esc_html__( 'Filter', 'woolentor' ), |
|---|
| 53 | ] |
|---|
| 54 | ); |
|---|
| 55 | |
|---|
| 56 | $repeater = new Repeater(); |
|---|
| 57 | |
|---|
| 58 | $repeater->add_control( |
|---|
| 59 | 'wl_filter_title', |
|---|
| 60 | [ |
|---|
| 61 | 'label' => esc_html__( 'Filter Title', 'woolentor' ), |
|---|
| 62 | 'type' => Controls_Manager::TEXT, |
|---|
| 63 | 'label_block' => true, |
|---|
| 64 | ] |
|---|
| 65 | ); |
|---|
| 66 | |
|---|
| 67 | $repeater->add_control( |
|---|
| 68 | 'wl_filter_placeholder', |
|---|
| 69 | [ |
|---|
| 70 | 'label' => esc_html__( 'Filter Placeholder', 'woolentor' ), |
|---|
| 71 | 'type' => Controls_Manager::TEXT, |
|---|
| 72 | 'label_block' => true, |
|---|
| 73 | ] |
|---|
| 74 | ); |
|---|
| 75 | |
|---|
| 76 | $repeater->add_control( |
|---|
| 77 | 'wl_filter_type', |
|---|
| 78 | [ |
|---|
| 79 | 'label' => esc_html__( 'Filter Type', 'woolentor' ), |
|---|
| 80 | 'type' => Controls_Manager::SELECT2, |
|---|
| 81 | 'options' => $filter_by + woolentor_get_taxonomies(), |
|---|
| 82 | 'label_block' => true, |
|---|
| 83 | ] |
|---|
| 84 | ); |
|---|
| 85 | |
|---|
| 86 | $repeater->add_control( |
|---|
| 87 | 'sort_by_asc_lavel', |
|---|
| 88 | [ |
|---|
| 89 | 'label' => esc_html__( 'Ascending order label', 'woolentor' ), |
|---|
| 90 | 'type' => Controls_Manager::TEXT, |
|---|
| 91 | 'label_block' => true, |
|---|
| 92 | 'default' => esc_html__('ASC','woolentor'), |
|---|
| 93 | 'condition'=>[ |
|---|
| 94 | 'wl_filter_type' => 'sort_by' |
|---|
| 95 | ] |
|---|
| 96 | ] |
|---|
| 97 | ); |
|---|
| 98 | $repeater->add_control( |
|---|
| 99 | 'sort_by_desc_lavel', |
|---|
| 100 | [ |
|---|
| 101 | 'label' => esc_html__( 'Descending order label', 'woolentor' ), |
|---|
| 102 | 'type' => Controls_Manager::TEXT, |
|---|
| 103 | 'label_block' => true, |
|---|
| 104 | 'default' => esc_html__('DESC','woolentor'), |
|---|
| 105 | 'condition'=>[ |
|---|
| 106 | 'wl_filter_type' => 'sort_by' |
|---|
| 107 | ] |
|---|
| 108 | ] |
|---|
| 109 | ); |
|---|
| 110 | |
|---|
| 111 | $repeater->add_responsive_control( |
|---|
| 112 | 'wl_filter_min_width', |
|---|
| 113 | [ |
|---|
| 114 | 'label' => esc_html__( 'Min Width', 'woolentor' ), |
|---|
| 115 | 'type' => Controls_Manager::SLIDER, |
|---|
| 116 | 'size_units' => [ 'px', '%' ], |
|---|
| 117 | 'range' => [ |
|---|
| 118 | 'px' => [ |
|---|
| 119 | 'min' => 0, |
|---|
| 120 | 'max' => 1000, |
|---|
| 121 | 'step' => 1, |
|---|
| 122 | ], |
|---|
| 123 | '%' => [ |
|---|
| 124 | 'min' => 0, |
|---|
| 125 | 'max' => 100, |
|---|
| 126 | ], |
|---|
| 127 | ], |
|---|
| 128 | 'default' => [ |
|---|
| 129 | 'unit' => 'px', |
|---|
| 130 | 'size' => 120, |
|---|
| 131 | ], |
|---|
| 132 | 'selectors' => [ |
|---|
| 133 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-single-item{{CURRENT_ITEM}} .select2-container .select2-search--inline .select2-search__field' => 'min-width: {{SIZE}}{{UNIT}};', |
|---|
| 134 | ], |
|---|
| 135 | ] |
|---|
| 136 | ); |
|---|
| 137 | |
|---|
| 138 | $repeater->add_responsive_control( |
|---|
| 139 | 'wl_filter_width', |
|---|
| 140 | [ |
|---|
| 141 | 'label' => esc_html__( 'Max Width', 'woolentor' ), |
|---|
| 142 | 'type' => Controls_Manager::SLIDER, |
|---|
| 143 | 'size_units' => [ 'px', '%' ], |
|---|
| 144 | 'range' => [ |
|---|
| 145 | 'px' => [ |
|---|
| 146 | 'min' => 0, |
|---|
| 147 | 'max' => 1000, |
|---|
| 148 | 'step' => 1, |
|---|
| 149 | ], |
|---|
| 150 | '%' => [ |
|---|
| 151 | 'min' => 0, |
|---|
| 152 | 'max' => 100, |
|---|
| 153 | ], |
|---|
| 154 | ], |
|---|
| 155 | 'selectors' => [ |
|---|
| 156 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-single-item{{CURRENT_ITEM}} .select2-container .select2-search--inline .select2-search__field' => 'max-width: {{SIZE}}{{UNIT}};', |
|---|
| 157 | ], |
|---|
| 158 | ] |
|---|
| 159 | ); |
|---|
| 160 | |
|---|
| 161 | $this->add_control( |
|---|
| 162 | 'wl_filter_list', |
|---|
| 163 | [ |
|---|
| 164 | 'label' => esc_html__( 'Filter List', 'woolentor' ), |
|---|
| 165 | 'type' => Controls_Manager::REPEATER, |
|---|
| 166 | 'fields' => $repeater->get_controls(), |
|---|
| 167 | 'default' => [ |
|---|
| 168 | [ |
|---|
| 169 | 'wl_filter_title' => esc_html__( 'Sort By', 'woolentor' ), |
|---|
| 170 | 'wl_filter_placeholder' => esc_html__( 'Sort By', 'woolentor' ), |
|---|
| 171 | 'wl_filter_type' => 'sort_by', |
|---|
| 172 | ], |
|---|
| 173 | [ |
|---|
| 174 | 'wl_filter_title' => esc_html__( 'Order By', 'woolentor' ), |
|---|
| 175 | 'wl_filter_placeholder' => esc_html__( 'Order By', 'woolentor' ), |
|---|
| 176 | 'wl_filter_type' => 'order_by', |
|---|
| 177 | ], |
|---|
| 178 | [ |
|---|
| 179 | 'wl_filter_title' => esc_html__( 'Pricing', 'woolentor' ), |
|---|
| 180 | 'wl_filter_placeholder' => esc_html__( 'Pricing', 'woolentor' ), |
|---|
| 181 | 'wl_filter_type' => 'price_by', |
|---|
| 182 | ], |
|---|
| 183 | ], |
|---|
| 184 | 'title_field' => '{{{ wl_filter_title }}}', |
|---|
| 185 | ] |
|---|
| 186 | ); |
|---|
| 187 | |
|---|
| 188 | $price_range = new Repeater(); |
|---|
| 189 | |
|---|
| 190 | $price_range->add_control( |
|---|
| 191 | 'min_price', |
|---|
| 192 | [ |
|---|
| 193 | 'label' => esc_html__( 'Min Price', 'woolentor' ), |
|---|
| 194 | 'type' => Controls_Manager::NUMBER, |
|---|
| 195 | 'default' => floor( $prices['min'] ), |
|---|
| 196 | ] |
|---|
| 197 | ); |
|---|
| 198 | |
|---|
| 199 | $price_range->add_control( |
|---|
| 200 | 'max_price', |
|---|
| 201 | [ |
|---|
| 202 | 'label' => esc_html__( 'Max Price', 'woolentor' ), |
|---|
| 203 | 'type' => Controls_Manager::NUMBER, |
|---|
| 204 | 'default' => ceil( $prices['max'] ), |
|---|
| 205 | ] |
|---|
| 206 | ); |
|---|
| 207 | |
|---|
| 208 | $price_range->add_control( |
|---|
| 209 | 'price_seprator', |
|---|
| 210 | [ |
|---|
| 211 | 'label' => esc_html__( 'Separator', 'woolentor' ), |
|---|
| 212 | 'type' => Controls_Manager::TEXT, |
|---|
| 213 | 'label_block' => true, |
|---|
| 214 | 'default'=> esc_html__( 'to', 'woolentor' ), |
|---|
| 215 | ] |
|---|
| 216 | ); |
|---|
| 217 | |
|---|
| 218 | $this->add_control( |
|---|
| 219 | 'price_range_list', |
|---|
| 220 | [ |
|---|
| 221 | 'label' => esc_html__( 'Price Range', 'woolentor' ), |
|---|
| 222 | 'type' => Controls_Manager::REPEATER, |
|---|
| 223 | 'fields' => $price_range->get_controls(), |
|---|
| 224 | 'separator' => 'before', |
|---|
| 225 | 'default' => [ |
|---|
| 226 | [ |
|---|
| 227 | 'min_price' => floor( $prices['min'] ), |
|---|
| 228 | 'max_price' => ceil( $prices['max'] ), |
|---|
| 229 | 'price_seprator' => esc_html__( 'to', 'woolentor' ), |
|---|
| 230 | ], |
|---|
| 231 | ], |
|---|
| 232 | 'title_field' => esc_html__( 'Price: {{{ min_price }}} {{{ price_seprator }}} {{{ max_price }}}', 'woolentor' ), |
|---|
| 233 | ] |
|---|
| 234 | ); |
|---|
| 235 | |
|---|
| 236 | $this->end_controls_section(); |
|---|
| 237 | |
|---|
| 238 | // Additional Option |
|---|
| 239 | $this->start_controls_section( |
|---|
| 240 | 'section_additional_option', |
|---|
| 241 | [ |
|---|
| 242 | 'label' => esc_html__( 'Additional Options', 'woolentor' ), |
|---|
| 243 | ] |
|---|
| 244 | ); |
|---|
| 245 | |
|---|
| 246 | $this->add_control( |
|---|
| 247 | 'wl_filter_area_title', |
|---|
| 248 | [ |
|---|
| 249 | 'label' => esc_html__( 'Title', 'woolentor' ), |
|---|
| 250 | 'type' => Controls_Manager::TEXT, |
|---|
| 251 | 'default'=>esc_html__( 'Filter', 'woolentor' ), |
|---|
| 252 | 'label_block' => true, |
|---|
| 253 | ] |
|---|
| 254 | ); |
|---|
| 255 | |
|---|
| 256 | $this->add_control( |
|---|
| 257 | 'show_search_form', |
|---|
| 258 | [ |
|---|
| 259 | 'label' => esc_html__( 'Search Form', 'woolentor' ), |
|---|
| 260 | 'type' => Controls_Manager::SWITCHER, |
|---|
| 261 | 'default'=>'yes', |
|---|
| 262 | ] |
|---|
| 263 | ); |
|---|
| 264 | |
|---|
| 265 | $this->add_control( |
|---|
| 266 | 'redirect_form_url', |
|---|
| 267 | [ |
|---|
| 268 | 'label' => esc_html__( 'Redirect Custom URL', 'woolentor' ), |
|---|
| 269 | 'type' => Controls_Manager::TEXT, |
|---|
| 270 | 'placeholder' => get_home_url( null, 'custom-search-page' ), |
|---|
| 271 | 'label_block'=>true, |
|---|
| 272 | 'condition' => [ |
|---|
| 273 | 'show_search_form' => 'yes' |
|---|
| 274 | ], |
|---|
| 275 | ] |
|---|
| 276 | ); |
|---|
| 277 | |
|---|
| 278 | $this->add_control( |
|---|
| 279 | 'show_filter_label', |
|---|
| 280 | [ |
|---|
| 281 | 'label' => esc_html__( 'Show Filter Label', 'woolentor' ), |
|---|
| 282 | 'type' => Controls_Manager::SWITCHER, |
|---|
| 283 | ] |
|---|
| 284 | ); |
|---|
| 285 | |
|---|
| 286 | $this->add_control( |
|---|
| 287 | 'show_filter_btton', |
|---|
| 288 | [ |
|---|
| 289 | 'label' => esc_html__( 'Show Filter Button', 'woolentor' ), |
|---|
| 290 | 'type' => Controls_Manager::SWITCHER, |
|---|
| 291 | 'default'=>'yes', |
|---|
| 292 | ] |
|---|
| 293 | ); |
|---|
| 294 | |
|---|
| 295 | $this->add_control( |
|---|
| 296 | 'form_field_placeholder', |
|---|
| 297 | [ |
|---|
| 298 | 'label' => esc_html__( 'Search Form Placeholder', 'woolentor' ), |
|---|
| 299 | 'type' => Controls_Manager::TEXT, |
|---|
| 300 | 'default'=>esc_html__( 'Search Products...', 'woolentor' ), |
|---|
| 301 | 'separator'=>'before', |
|---|
| 302 | 'label_block' => true, |
|---|
| 303 | 'condition'=>[ |
|---|
| 304 | 'show_search_form'=>'yes', |
|---|
| 305 | ] |
|---|
| 306 | ] |
|---|
| 307 | ); |
|---|
| 308 | |
|---|
| 309 | $this->add_control( |
|---|
| 310 | 'form_submit_button_icon', |
|---|
| 311 | [ |
|---|
| 312 | 'label' => esc_html__( 'Search Button Icon', 'woolentor' ), |
|---|
| 313 | 'type' => Controls_Manager::ICONS, |
|---|
| 314 | 'default' => [ |
|---|
| 315 | 'value' => 'fa fa-search', |
|---|
| 316 | 'library' => 'solid', |
|---|
| 317 | ], |
|---|
| 318 | 'fa4compatibility' => 'formsubmitbuttonicon', |
|---|
| 319 | 'condition'=>[ |
|---|
| 320 | 'show_search_form'=>'yes', |
|---|
| 321 | ] |
|---|
| 322 | ] |
|---|
| 323 | ); |
|---|
| 324 | |
|---|
| 325 | $this->add_control( |
|---|
| 326 | 'filter_button_icon', |
|---|
| 327 | [ |
|---|
| 328 | 'label' => esc_html__( 'Filter Button Icon', 'woolentor' ), |
|---|
| 329 | 'type' => Controls_Manager::ICONS, |
|---|
| 330 | 'default' => [ |
|---|
| 331 | 'value' => 'fas fa-filter', |
|---|
| 332 | 'library' => 'solid', |
|---|
| 333 | ], |
|---|
| 334 | 'fa4compatibility' => 'filterbuttonicon', |
|---|
| 335 | 'condition'=>[ |
|---|
| 336 | 'show_filter_btton'=>'yes', |
|---|
| 337 | ] |
|---|
| 338 | ] |
|---|
| 339 | ); |
|---|
| 340 | |
|---|
| 341 | $this->end_controls_section(); |
|---|
| 342 | |
|---|
| 343 | // Area Style Section |
|---|
| 344 | $this->start_controls_section( |
|---|
| 345 | 'wlproduct_filter_area_style', |
|---|
| 346 | [ |
|---|
| 347 | 'label' => esc_html__( 'Area', 'woolentor' ), |
|---|
| 348 | 'tab' => Controls_Manager::TAB_STYLE, |
|---|
| 349 | ] |
|---|
| 350 | ); |
|---|
| 351 | |
|---|
| 352 | $this->add_group_control( |
|---|
| 353 | \Elementor\Group_Control_Border::get_type(), |
|---|
| 354 | [ |
|---|
| 355 | 'name' => 'area_border', |
|---|
| 356 | 'label' => esc_html__( 'Border', 'woolentor' ), |
|---|
| 357 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-heaer-box-area', |
|---|
| 358 | ] |
|---|
| 359 | ); |
|---|
| 360 | |
|---|
| 361 | $this->add_responsive_control( |
|---|
| 362 | 'area_border_radius', |
|---|
| 363 | [ |
|---|
| 364 | 'label' => esc_html__( 'Border Radius', 'woolentor' ), |
|---|
| 365 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 366 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 367 | 'selectors' => [ |
|---|
| 368 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-heaer-box-area' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 369 | ], |
|---|
| 370 | ] |
|---|
| 371 | ); |
|---|
| 372 | |
|---|
| 373 | $this->add_responsive_control( |
|---|
| 374 | 'area_padding', |
|---|
| 375 | [ |
|---|
| 376 | 'label' => esc_html__( 'Padding', 'woolentor' ), |
|---|
| 377 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 378 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 379 | 'selectors' => [ |
|---|
| 380 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-heaer-box-area' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 381 | ], |
|---|
| 382 | ] |
|---|
| 383 | ); |
|---|
| 384 | |
|---|
| 385 | $this->add_responsive_control( |
|---|
| 386 | 'area_margin', |
|---|
| 387 | [ |
|---|
| 388 | 'label' => esc_html__( 'Margin', 'woolentor' ), |
|---|
| 389 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 390 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 391 | 'selectors' => [ |
|---|
| 392 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-heaer-box-area' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 393 | ], |
|---|
| 394 | ] |
|---|
| 395 | ); |
|---|
| 396 | |
|---|
| 397 | $this->add_group_control( |
|---|
| 398 | \Elementor\Group_Control_Background::get_type(), |
|---|
| 399 | [ |
|---|
| 400 | 'name' => 'area_background', |
|---|
| 401 | 'label' => esc_html__( 'Background', 'woolentor' ), |
|---|
| 402 | 'types' => [ 'classic', 'gradient' ], |
|---|
| 403 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-heaer-box-area', |
|---|
| 404 | ] |
|---|
| 405 | ); |
|---|
| 406 | |
|---|
| 407 | $this->add_group_control( |
|---|
| 408 | \Elementor\Group_Control_Box_Shadow::get_type(), |
|---|
| 409 | [ |
|---|
| 410 | 'name' => 'area_box_shadow', |
|---|
| 411 | 'label' => esc_html__( 'Box Shadow', 'woolentor' ), |
|---|
| 412 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-heaer-box-area', |
|---|
| 413 | ] |
|---|
| 414 | ); |
|---|
| 415 | |
|---|
| 416 | $this->end_controls_section(); |
|---|
| 417 | |
|---|
| 418 | // Title Style Section |
|---|
| 419 | $this->start_controls_section( |
|---|
| 420 | 'wlproduct_filter_title_style', |
|---|
| 421 | [ |
|---|
| 422 | 'label' => esc_html__( 'Title', 'woolentor' ), |
|---|
| 423 | 'tab' => Controls_Manager::TAB_STYLE, |
|---|
| 424 | 'condition'=>[ |
|---|
| 425 | 'wl_filter_area_title!'=>'' |
|---|
| 426 | ] |
|---|
| 427 | ] |
|---|
| 428 | ); |
|---|
| 429 | |
|---|
| 430 | $this->add_control( |
|---|
| 431 | 'title_color', |
|---|
| 432 | [ |
|---|
| 433 | 'label' => esc_html__( 'Color', 'woolentor' ), |
|---|
| 434 | 'type' => Controls_Manager::COLOR, |
|---|
| 435 | 'selectors' => [ |
|---|
| 436 | '{{WRAPPER}} h2.wl_hoz_filter_title' => 'color: {{VALUE}}', |
|---|
| 437 | ], |
|---|
| 438 | ] |
|---|
| 439 | ); |
|---|
| 440 | |
|---|
| 441 | $this->add_group_control( |
|---|
| 442 | \Elementor\Group_Control_Typography::get_type(), |
|---|
| 443 | [ |
|---|
| 444 | 'name' => 'title_typography', |
|---|
| 445 | 'label' => esc_html__( 'Typography', 'woolentor' ), |
|---|
| 446 | 'selector' => '{{WRAPPER}} h2.wl_hoz_filter_title', |
|---|
| 447 | ] |
|---|
| 448 | ); |
|---|
| 449 | |
|---|
| 450 | $this->add_group_control( |
|---|
| 451 | \Elementor\Group_Control_Border::get_type(), |
|---|
| 452 | [ |
|---|
| 453 | 'name' => 'title_border', |
|---|
| 454 | 'label' => esc_html__( 'Border', 'woolentor' ), |
|---|
| 455 | 'selector' => '{{WRAPPER}} h2.wl_hoz_filter_title', |
|---|
| 456 | ] |
|---|
| 457 | ); |
|---|
| 458 | |
|---|
| 459 | $this->add_responsive_control( |
|---|
| 460 | 'title_padding', |
|---|
| 461 | [ |
|---|
| 462 | 'label' => esc_html__( 'Padding', 'woolentor' ), |
|---|
| 463 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 464 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 465 | 'selectors' => [ |
|---|
| 466 | '{{WRAPPER}} h2.wl_hoz_filter_title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 467 | ], |
|---|
| 468 | ] |
|---|
| 469 | ); |
|---|
| 470 | |
|---|
| 471 | $this->add_responsive_control( |
|---|
| 472 | 'title_margin', |
|---|
| 473 | [ |
|---|
| 474 | 'label' => esc_html__( 'Margin', 'woolentor' ), |
|---|
| 475 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 476 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 477 | 'selectors' => [ |
|---|
| 478 | '{{WRAPPER}} h2.wl_hoz_filter_title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 479 | ], |
|---|
| 480 | ] |
|---|
| 481 | ); |
|---|
| 482 | |
|---|
| 483 | $this->end_controls_section(); |
|---|
| 484 | |
|---|
| 485 | // Filter Label Style Section |
|---|
| 486 | $this->start_controls_section( |
|---|
| 487 | 'wlproduct_filter_label_style', |
|---|
| 488 | [ |
|---|
| 489 | 'label' => esc_html__( 'Label', 'woolentor' ), |
|---|
| 490 | 'tab' => Controls_Manager::TAB_STYLE, |
|---|
| 491 | 'condition'=>[ |
|---|
| 492 | 'show_filter_label'=>'yes' |
|---|
| 493 | ] |
|---|
| 494 | ] |
|---|
| 495 | ); |
|---|
| 496 | |
|---|
| 497 | $this->add_control( |
|---|
| 498 | 'filter_label_color', |
|---|
| 499 | [ |
|---|
| 500 | 'label' => esc_html__( 'Color', 'woolentor' ), |
|---|
| 501 | 'type' => Controls_Manager::COLOR, |
|---|
| 502 | 'selectors' => [ |
|---|
| 503 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-field-wrap .woolentor-filter-single-item label' => 'color: {{VALUE}}', |
|---|
| 504 | ], |
|---|
| 505 | ] |
|---|
| 506 | ); |
|---|
| 507 | |
|---|
| 508 | $this->add_group_control( |
|---|
| 509 | \Elementor\Group_Control_Typography::get_type(), |
|---|
| 510 | [ |
|---|
| 511 | 'name' => 'filter_label_typography', |
|---|
| 512 | 'label' => esc_html__( 'Typography', 'woolentor' ), |
|---|
| 513 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-field-wrap .woolentor-filter-single-item label', |
|---|
| 514 | ] |
|---|
| 515 | ); |
|---|
| 516 | |
|---|
| 517 | $this->add_group_control( |
|---|
| 518 | \Elementor\Group_Control_Border::get_type(), |
|---|
| 519 | [ |
|---|
| 520 | 'name' => 'filter_label_border', |
|---|
| 521 | 'label' => esc_html__( 'Border', 'woolentor' ), |
|---|
| 522 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-field-wrap .woolentor-filter-single-item label', |
|---|
| 523 | ] |
|---|
| 524 | ); |
|---|
| 525 | |
|---|
| 526 | $this->add_responsive_control( |
|---|
| 527 | 'filter_label_padding', |
|---|
| 528 | [ |
|---|
| 529 | 'label' => esc_html__( 'Padding', 'woolentor' ), |
|---|
| 530 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 531 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 532 | 'selectors' => [ |
|---|
| 533 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-field-wrap .woolentor-filter-single-item label' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 534 | ], |
|---|
| 535 | ] |
|---|
| 536 | ); |
|---|
| 537 | |
|---|
| 538 | $this->add_responsive_control( |
|---|
| 539 | 'filter_label_margin', |
|---|
| 540 | [ |
|---|
| 541 | 'label' => esc_html__( 'Margin', 'woolentor' ), |
|---|
| 542 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 543 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 544 | 'selectors' => [ |
|---|
| 545 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-field-wrap .woolentor-filter-single-item label' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 546 | ], |
|---|
| 547 | ] |
|---|
| 548 | ); |
|---|
| 549 | |
|---|
| 550 | $this->end_controls_section(); |
|---|
| 551 | |
|---|
| 552 | // Search Form Style Section |
|---|
| 553 | $this->start_controls_section( |
|---|
| 554 | 'wlproduct_filter_search_form_style', |
|---|
| 555 | [ |
|---|
| 556 | 'label' => esc_html__( 'Search Form', 'woolentor' ), |
|---|
| 557 | 'tab' => Controls_Manager::TAB_STYLE, |
|---|
| 558 | 'condition'=>[ |
|---|
| 559 | 'show_search_form'=>'yes' |
|---|
| 560 | ] |
|---|
| 561 | ] |
|---|
| 562 | ); |
|---|
| 563 | |
|---|
| 564 | $this->add_control( |
|---|
| 565 | 'form_inputbox', |
|---|
| 566 | [ |
|---|
| 567 | 'label' => esc_html__( 'Input Box', 'woolentor' ), |
|---|
| 568 | 'type' => Controls_Manager::HEADING, |
|---|
| 569 | 'separator' => 'after', |
|---|
| 570 | ] |
|---|
| 571 | ); |
|---|
| 572 | |
|---|
| 573 | $this->add_control( |
|---|
| 574 | 'inputbox_color', |
|---|
| 575 | [ |
|---|
| 576 | 'label' => esc_html__( 'Color', 'woolentor' ), |
|---|
| 577 | 'type' => Controls_Manager::COLOR, |
|---|
| 578 | 'selectors' => [ |
|---|
| 579 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-box' => 'color: {{VALUE}}', |
|---|
| 580 | ], |
|---|
| 581 | ] |
|---|
| 582 | ); |
|---|
| 583 | |
|---|
| 584 | $this->add_group_control( |
|---|
| 585 | \Elementor\Group_Control_Background::get_type(), |
|---|
| 586 | [ |
|---|
| 587 | 'name' => 'inputbox_background', |
|---|
| 588 | 'label' => esc_html__( 'Background', 'woolentor' ), |
|---|
| 589 | 'types' => [ 'classic', 'gradient' ], |
|---|
| 590 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-box', |
|---|
| 591 | ] |
|---|
| 592 | ); |
|---|
| 593 | |
|---|
| 594 | $this->add_group_control( |
|---|
| 595 | \Elementor\Group_Control_Typography::get_type(), |
|---|
| 596 | [ |
|---|
| 597 | 'name' => 'inputbox_typography', |
|---|
| 598 | 'label' => esc_html__( 'Typography', 'woolentor' ), |
|---|
| 599 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-box', |
|---|
| 600 | ] |
|---|
| 601 | ); |
|---|
| 602 | |
|---|
| 603 | $this->add_group_control( |
|---|
| 604 | \Elementor\Group_Control_Border::get_type(), |
|---|
| 605 | [ |
|---|
| 606 | 'name' => 'inputbox_border', |
|---|
| 607 | 'label' => esc_html__( 'Border', 'woolentor' ), |
|---|
| 608 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-box', |
|---|
| 609 | ] |
|---|
| 610 | ); |
|---|
| 611 | |
|---|
| 612 | $this->add_responsive_control( |
|---|
| 613 | 'inputbox_border_radius', |
|---|
| 614 | [ |
|---|
| 615 | 'label' => esc_html__( 'Border Radius', 'woolentor' ), |
|---|
| 616 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 617 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 618 | 'selectors' => [ |
|---|
| 619 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-box' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 620 | ], |
|---|
| 621 | ] |
|---|
| 622 | ); |
|---|
| 623 | |
|---|
| 624 | $this->add_responsive_control( |
|---|
| 625 | 'inputbox_padding', |
|---|
| 626 | [ |
|---|
| 627 | 'label' => esc_html__( 'Padding', 'woolentor' ), |
|---|
| 628 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 629 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 630 | 'selectors' => [ |
|---|
| 631 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-box' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 632 | ], |
|---|
| 633 | ] |
|---|
| 634 | ); |
|---|
| 635 | |
|---|
| 636 | $this->add_control( |
|---|
| 637 | 'form_submit_button', |
|---|
| 638 | [ |
|---|
| 639 | 'label' => esc_html__( 'Submit Button', 'woolentor' ), |
|---|
| 640 | 'type' => Controls_Manager::HEADING, |
|---|
| 641 | 'separator' => 'before', |
|---|
| 642 | ] |
|---|
| 643 | ); |
|---|
| 644 | |
|---|
| 645 | $this->start_controls_tabs('submit_button_style_tabs'); |
|---|
| 646 | |
|---|
| 647 | // Button Normal Style |
|---|
| 648 | $this->start_controls_tab( |
|---|
| 649 | 'submit_button_style_normal_tab', |
|---|
| 650 | [ |
|---|
| 651 | 'label' => esc_html__( 'Normal', 'woolentor' ), |
|---|
| 652 | ] |
|---|
| 653 | ); |
|---|
| 654 | |
|---|
| 655 | $this->add_control( |
|---|
| 656 | 'submit_button_color', |
|---|
| 657 | [ |
|---|
| 658 | 'label' => esc_html__( 'Color', 'woolentor' ), |
|---|
| 659 | 'type' => Controls_Manager::COLOR, |
|---|
| 660 | 'selectors' => [ |
|---|
| 661 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-inner-btn' => 'color: {{VALUE}}', |
|---|
| 662 | ], |
|---|
| 663 | ] |
|---|
| 664 | ); |
|---|
| 665 | |
|---|
| 666 | $this->add_responsive_control( |
|---|
| 667 | 'submit_button_icon_size', |
|---|
| 668 | [ |
|---|
| 669 | 'label' => esc_html__( 'Font Size', 'woolentor' ), |
|---|
| 670 | 'type' => Controls_Manager::SLIDER, |
|---|
| 671 | 'selectors' => [ |
|---|
| 672 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-inner-btn' => 'font-size: {{SIZE}}{{UNIT}};', |
|---|
| 673 | ], |
|---|
| 674 | ] |
|---|
| 675 | ); |
|---|
| 676 | |
|---|
| 677 | $this->end_controls_tab(); |
|---|
| 678 | |
|---|
| 679 | // Button Hover Style |
|---|
| 680 | $this->start_controls_tab( |
|---|
| 681 | 'submit_button_style_hover_tab', |
|---|
| 682 | [ |
|---|
| 683 | 'label' => esc_html__( 'Hover', 'woolentor' ), |
|---|
| 684 | ] |
|---|
| 685 | ); |
|---|
| 686 | $this->add_control( |
|---|
| 687 | 'submit_button_hover_color', |
|---|
| 688 | [ |
|---|
| 689 | 'label' => esc_html__( 'Color', 'woolentor' ), |
|---|
| 690 | 'type' => Controls_Manager::COLOR, |
|---|
| 691 | 'selectors' => [ |
|---|
| 692 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-header-top-area .woolentor-search-input-box .input-inner-btn:hover' => 'color: {{VALUE}}', |
|---|
| 693 | ], |
|---|
| 694 | ] |
|---|
| 695 | ); |
|---|
| 696 | |
|---|
| 697 | $this->end_controls_tab(); |
|---|
| 698 | |
|---|
| 699 | $this->end_controls_tabs(); |
|---|
| 700 | |
|---|
| 701 | $this->end_controls_section(); |
|---|
| 702 | |
|---|
| 703 | // Filter Menu |
|---|
| 704 | $this->start_controls_section( |
|---|
| 705 | 'wlproduct_filter_menu_style', |
|---|
| 706 | [ |
|---|
| 707 | 'label' => esc_html__( 'Filter Menu', 'woolentor' ), |
|---|
| 708 | 'tab' => Controls_Manager::TAB_STYLE, |
|---|
| 709 | ] |
|---|
| 710 | ); |
|---|
| 711 | |
|---|
| 712 | $this->add_control( |
|---|
| 713 | 'menu_label_placeholder_color', |
|---|
| 714 | [ |
|---|
| 715 | 'label' => esc_html__( 'Placeholder Color', 'woolentor' ), |
|---|
| 716 | 'type' => Controls_Manager::COLOR, |
|---|
| 717 | 'selectors' => [ |
|---|
| 718 | '{{WRAPPER}} .woolentor-filter-single-item .select2-container--default .select2-selection--single .select2-selection__placeholder' => 'color: {{VALUE}}', |
|---|
| 719 | '{{WRAPPER}} .woolentor-filter-single-item .select2-container .select2-search--inline .select2-search__field::-webkit-input-placeholder' => 'color: {{VALUE}};opacity:1;', |
|---|
| 720 | '{{WRAPPER}} .woolentor-filter-single-item .select2-container .select2-search--inline .select2-search__field::-moz-placeholder' => 'color: {{VALUE}};opacity:1;', |
|---|
| 721 | '{{WRAPPER}} .woolentor-filter-single-item .select2-container .select2-search--inline .select2-search__field:-ms-input-placeholder' => 'color: {{VALUE}};opacity:1;', |
|---|
| 722 | ], |
|---|
| 723 | ] |
|---|
| 724 | ); |
|---|
| 725 | |
|---|
| 726 | $this->add_group_control( |
|---|
| 727 | \Elementor\Group_Control_Border::get_type(), |
|---|
| 728 | [ |
|---|
| 729 | 'name' => 'menu_label_border', |
|---|
| 730 | 'label' => esc_html__( 'Border', 'woolentor' ), |
|---|
| 731 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .select2-container .select2-selection--single,{{WRAPPER}} .woolentor-horizontal-filter-wrap .select2-container .select2-selection--multiple', |
|---|
| 732 | ] |
|---|
| 733 | ); |
|---|
| 734 | |
|---|
| 735 | $this->add_responsive_control( |
|---|
| 736 | 'menu_label_border_radius', |
|---|
| 737 | [ |
|---|
| 738 | 'label' => esc_html__( 'Border Radius', 'woolentor' ), |
|---|
| 739 | 'type' => Controls_Manager::DIMENSIONS, |
|---|
| 740 | 'size_units' => [ 'px', '%', 'em' ], |
|---|
| 741 | 'selectors' => [ |
|---|
| 742 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .select2-container .select2-selection--single' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 743 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .select2-container .select2-selection--multiple' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
|---|
| 744 | ], |
|---|
| 745 | ] |
|---|
| 746 | ); |
|---|
| 747 | |
|---|
| 748 | $this->add_control( |
|---|
| 749 | 'menu_label_color', |
|---|
| 750 | [ |
|---|
| 751 | 'label' => esc_html__( 'Color', 'woolentor' ), |
|---|
| 752 | 'type' => Controls_Manager::COLOR, |
|---|
| 753 | 'selectors' => [ |
|---|
| 754 | '{{WRAPPER}} .woolentor-select-drop .select2-results__option' => 'color: {{VALUE}}', |
|---|
| 755 | '{{WRAPPER}} .woolentor-select-drop .select2-results__option::before' => 'border-color: {{VALUE}}', |
|---|
| 756 | ], |
|---|
| 757 | ] |
|---|
| 758 | ); |
|---|
| 759 | |
|---|
| 760 | $this->add_control( |
|---|
| 761 | 'menu_label_hover_color', |
|---|
| 762 | [ |
|---|
| 763 | 'label' => esc_html__( 'Hover Color', 'woolentor' ), |
|---|
| 764 | 'type' => Controls_Manager::COLOR, |
|---|
| 765 | 'selectors' => [ |
|---|
| 766 | '{{WRAPPER}} .woolentor-select-drop .select2-container--default .select2-results__option--highlighted[aria-selected="true"]' => 'color: {{VALUE}}', |
|---|
| 767 | ], |
|---|
| 768 | ] |
|---|
| 769 | ); |
|---|
| 770 | |
|---|
| 771 | $this->add_group_control( |
|---|
| 772 | \Elementor\Group_Control_Background::get_type(), |
|---|
| 773 | [ |
|---|
| 774 | 'name' => 'menu_label_hover_background', |
|---|
| 775 | 'label' => esc_html__( 'Background', 'woolentor' ), |
|---|
| 776 | 'types' => [ 'classic', 'gradient' ], |
|---|
| 777 | 'fields_options'=>[ |
|---|
| 778 | 'background'=>[ |
|---|
| 779 | 'label' => esc_html__( 'Hover Background', 'woolentor' ), |
|---|
| 780 | ], |
|---|
| 781 | ], |
|---|
| 782 | 'exclude'=>['image'], |
|---|
| 783 | 'selector' => '{{WRAPPER}} .woolentor-select-drop .select2-container--default .select2-results__option--highlighted[aria-selected="true"]', |
|---|
| 784 | ] |
|---|
| 785 | ); |
|---|
| 786 | |
|---|
| 787 | $this->add_responsive_control( |
|---|
| 788 | 'menu_alignment', |
|---|
| 789 | [ |
|---|
| 790 | 'label' => esc_html__( 'Alignment', 'woolentor' ), |
|---|
| 791 | 'type' => Controls_Manager::CHOOSE, |
|---|
| 792 | 'options' => [ |
|---|
| 793 | 'flex-start' => [ |
|---|
| 794 | 'title' => esc_html__( 'Left', 'woolentor' ), |
|---|
| 795 | 'icon' => 'eicon-text-align-left', |
|---|
| 796 | ], |
|---|
| 797 | 'center' => [ |
|---|
| 798 | 'title' => esc_html__( 'Center', 'woolentor' ), |
|---|
| 799 | 'icon' => 'eicon-text-align-center', |
|---|
| 800 | ], |
|---|
| 801 | 'flex-end' => [ |
|---|
| 802 | 'title' => esc_html__( 'Right', 'woolentor' ), |
|---|
| 803 | 'icon' => 'eicon-text-align-right', |
|---|
| 804 | ], |
|---|
| 805 | ], |
|---|
| 806 | 'selectors' => [ |
|---|
| 807 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-filter-field-wrap' => 'justify-content: {{VALUE}};', |
|---|
| 808 | ], |
|---|
| 809 | 'default' => 'center', |
|---|
| 810 | ] |
|---|
| 811 | ); |
|---|
| 812 | |
|---|
| 813 | $this->end_controls_section(); |
|---|
| 814 | |
|---|
| 815 | // Filter Button Style Section |
|---|
| 816 | $this->start_controls_section( |
|---|
| 817 | 'wlproduct_filter_button_style', |
|---|
| 818 | [ |
|---|
| 819 | 'label' => esc_html__( 'Filter Button', 'woolentor' ), |
|---|
| 820 | 'tab' => Controls_Manager::TAB_STYLE, |
|---|
| 821 | 'condition'=>[ |
|---|
| 822 | 'show_filter_btton'=>'yes' |
|---|
| 823 | ] |
|---|
| 824 | ] |
|---|
| 825 | ); |
|---|
| 826 | $this->start_controls_tabs('filter_button_style_tabs'); |
|---|
| 827 | |
|---|
| 828 | // Button Normal Style |
|---|
| 829 | $this->start_controls_tab( |
|---|
| 830 | 'filter_button_style_normal_tab', |
|---|
| 831 | [ |
|---|
| 832 | 'label' => esc_html__( 'Normal', 'woolentor' ), |
|---|
| 833 | ] |
|---|
| 834 | ); |
|---|
| 835 | |
|---|
| 836 | $this->add_control( |
|---|
| 837 | 'filter_button_color', |
|---|
| 838 | [ |
|---|
| 839 | 'label' => esc_html__( 'Color', 'woolentor' ), |
|---|
| 840 | 'type' => Controls_Manager::COLOR, |
|---|
| 841 | 'selectors' => [ |
|---|
| 842 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-search-filter-custom .filter-icon' => 'color: {{VALUE}}', |
|---|
| 843 | ], |
|---|
| 844 | ] |
|---|
| 845 | ); |
|---|
| 846 | |
|---|
| 847 | $this->add_responsive_control( |
|---|
| 848 | 'filter_button_icon_size', |
|---|
| 849 | [ |
|---|
| 850 | 'label' => esc_html__( 'Font Size', 'woolentor' ), |
|---|
| 851 | 'type' => Controls_Manager::SLIDER, |
|---|
| 852 | 'selectors' => [ |
|---|
| 853 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-search-filter-custom .filter-icon' => 'font-size: {{SIZE}}{{UNIT}};', |
|---|
| 854 | ], |
|---|
| 855 | ] |
|---|
| 856 | ); |
|---|
| 857 | |
|---|
| 858 | $this->add_group_control( |
|---|
| 859 | \Elementor\Group_Control_Background::get_type(), |
|---|
| 860 | [ |
|---|
| 861 | 'name' => 'filter_button_background', |
|---|
| 862 | 'label' => esc_html__( 'Background', 'woolentor' ), |
|---|
| 863 | 'types' => [ 'classic', 'gradient' ], |
|---|
| 864 | 'exclude'=>['image'], |
|---|
| 865 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-search-filter-custom .filter-icon', |
|---|
| 866 | ] |
|---|
| 867 | ); |
|---|
| 868 | |
|---|
| 869 | $this->end_controls_tab(); |
|---|
| 870 | |
|---|
| 871 | // Button Hover Style |
|---|
| 872 | $this->start_controls_tab( |
|---|
| 873 | 'filter_button_style_hover_tab', |
|---|
| 874 | [ |
|---|
| 875 | 'label' => esc_html__( 'Hover', 'woolentor' ), |
|---|
| 876 | ] |
|---|
| 877 | ); |
|---|
| 878 | $this->add_control( |
|---|
| 879 | 'filter_button_hover_color', |
|---|
| 880 | [ |
|---|
| 881 | 'label' => esc_html__( 'Color', 'woolentor' ), |
|---|
| 882 | 'type' => Controls_Manager::COLOR, |
|---|
| 883 | 'selectors' => [ |
|---|
| 884 | '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-search-filter-custom .filter-icon:hover' => 'color: {{VALUE}}', |
|---|
| 885 | ], |
|---|
| 886 | ] |
|---|
| 887 | ); |
|---|
| 888 | |
|---|
| 889 | $this->add_group_control( |
|---|
| 890 | \Elementor\Group_Control_Background::get_type(), |
|---|
| 891 | [ |
|---|
| 892 | 'name' => 'filter_button_hover_background', |
|---|
| 893 | 'label' => esc_html__( 'Background', 'woolentor' ), |
|---|
| 894 | 'types' => [ 'classic', 'gradient' ], |
|---|
| 895 | 'exclude'=>['image'], |
|---|
| 896 | 'selector' => '{{WRAPPER}} .woolentor-horizontal-filter-wrap .woolentor-search-filter-custom .filter-icon:hover', |
|---|
| 897 | ] |
|---|
| 898 | ); |
|---|
| 899 | |
|---|
| 900 | |
|---|
| 901 | $this->end_controls_tab(); |
|---|
| 902 | |
|---|
| 903 | $this->end_controls_tabs(); |
|---|
| 904 | |
|---|
| 905 | $this->end_controls_section(); |
|---|
| 906 | |
|---|
| 907 | |
|---|
| 908 | } |
|---|
| 909 | |
|---|
| 910 | |
|---|
| 911 | protected function render( $instance = [] ) { |
|---|
| 912 | $settings = $this->get_settings_for_display(); |
|---|
| 913 | $id = $this->get_id(); |
|---|
| 914 | $currency_symbol = get_woocommerce_currency_symbol(); |
|---|
| 915 | |
|---|
| 916 | $filter_list = $settings['wl_filter_list']; |
|---|
| 917 | |
|---|
| 918 | |
|---|
| 919 | global $wp; |
|---|
| 920 | if ( '' == get_option('permalink_structure' ) ) { |
|---|
| 921 | $current_url = remove_query_arg(array('page', 'paged'), add_query_arg($wp->query_string, '', home_url($wp->request))); |
|---|
| 922 | } else { |
|---|
| 923 | $current_url = preg_replace('%\/page/[0-9]+%', '', home_url(trailingslashit($wp->request))); |
|---|
| 924 | } |
|---|
| 925 | |
|---|
| 926 | if( !empty( $settings['form_submit_button_icon']['value'] ) ){ |
|---|
| 927 | $submit_btton_icon = woolentor_render_icon( $settings, 'form_submit_button_icon', 'formsubmitbuttonicon' ); |
|---|
| 928 | }else{ |
|---|
| 929 | $submit_btton_icon = '<i class="fa fa-search"></i>'; |
|---|
| 930 | } |
|---|
| 931 | |
|---|
| 932 | if( !empty( $settings['filter_button_icon']['value'] ) ){ |
|---|
| 933 | $filter_btton_icon = woolentor_render_icon( $settings, 'filter_button_icon', 'filterbuttonicon' ); |
|---|
| 934 | }else{ |
|---|
| 935 | $filter_btton_icon = '<i class="fas fa-filter"></i>'; |
|---|
| 936 | } |
|---|
| 937 | |
|---|
| 938 | ?> |
|---|
| 939 | <div class="woolentor-horizontal-filter-wrap"> |
|---|
| 940 | <!-- Heaer Box Area Start --> |
|---|
| 941 | <div class="woolentor-heaer-box-area"> |
|---|
| 942 | |
|---|
| 943 | <div class="woolentor-filter-header-top-area"> |
|---|
| 944 | <div class="woolentor-header-left-side"> |
|---|
| 945 | <?php |
|---|
| 946 | if( !empty( $settings['wl_filter_area_title'] ) ){ |
|---|
| 947 | echo '<h2 class="wl_hoz_filter_title">'.esc_html($settings['wl_filter_area_title']).'</h2>'; |
|---|
| 948 | } |
|---|
| 949 | ?> |
|---|
| 950 | </div> |
|---|
| 951 | <div class="woolentor-header-right-side"> |
|---|
| 952 | <?php |
|---|
| 953 | if( $settings['show_search_form'] === 'yes' ): |
|---|
| 954 | |
|---|
| 955 | if ( isset( $_GET['q'] ) || isset( $_GET['s'] ) ) { |
|---|
| 956 | $s = !empty( $_GET['s'] ) ? $_GET['s'] : ''; |
|---|
| 957 | $q = !empty( $_GET['q'] ) ? $_GET['q'] : ''; |
|---|
| 958 | $search_value = !empty( $q ) ? $q : $s; |
|---|
| 959 | }else{ |
|---|
| 960 | $search_value = ''; |
|---|
| 961 | } |
|---|
| 962 | |
|---|
| 963 | if( !empty( $settings['redirect_form_url'] ) ){ |
|---|
| 964 | $form_action = $settings['redirect_form_url']; |
|---|
| 965 | }else{ |
|---|
| 966 | $form_action = $current_url; |
|---|
| 967 | } |
|---|
| 968 | |
|---|
| 969 | ?> |
|---|
| 970 | <form class="woolentor-header-search-form" role="search" method="get" action="<?php echo esc_url( $form_action ); ?>"> |
|---|
| 971 | <div class="woolentor-search-input-box"> |
|---|
| 972 | <input class="input-box" type="search" placeholder="<?php echo esc_attr_x( $settings['form_field_placeholder'], 'placeholder', 'woolentor' ); ?>" value="<?php echo esc_attr( $search_value ); ?>" name="q" title="<?php echo esc_attr_x( 'Search for:', 'label', 'woolentor' ); ?>" /> |
|---|
| 973 | <button class="input-inner-btn" type="submit" aria-label="<?php echo esc_attr__( 'Search', 'woolentor' );?>"><?php echo $submit_btton_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></button> |
|---|
| 974 | </div> |
|---|
| 975 | </form> |
|---|
| 976 | <?php endif; ?> |
|---|
| 977 | |
|---|
| 978 | <?php if( $settings['show_filter_btton'] == 'yes' ): ?> |
|---|
| 979 | <div class="woolentor-search-filter-custom"> |
|---|
| 980 | <a href="#" id="filter-toggle-<?php echo esc_attr($id); ?>" class="filter-icon"><?php echo $filter_btton_icon; ?></a> |
|---|
| 981 | </div> |
|---|
| 982 | <?php endif; ?> |
|---|
| 983 | </div> |
|---|
| 984 | </div> |
|---|
| 985 | |
|---|
| 986 | <div id="filter-item-<?php echo esc_attr($id); ?>" class="filter-item"> |
|---|
| 987 | <div class="woolentor-filter-field-area"> |
|---|
| 988 | <div class="woolentor-filter-field-wrap"> |
|---|
| 989 | <?php |
|---|
| 990 | if( isset( $filter_list ) ){ |
|---|
| 991 | foreach ( $filter_list as $filter_key => $filter_item ) { |
|---|
| 992 | |
|---|
| 993 | $filter_label = ''; |
|---|
| 994 | if( 'yes' === $settings['show_filter_label'] ){ |
|---|
| 995 | $filter_label = '<label for="woolentor-field-for-'.esc_attr($filter_item['_id']).'">'.esc_html($filter_item['wl_filter_title']).'</label>'; |
|---|
| 996 | } |
|---|
| 997 | |
|---|
| 998 | if( 'sort_by' === $filter_item['wl_filter_type'] ){ |
|---|
| 999 | $wlsort = ( isset( $_GET['wlsort'] ) && !empty( $_GET['wlsort'] ) ) ? $_GET['wlsort'] : ''; |
|---|
| 1000 | $sort_by_asc_lavel = isset( $filter_item['sort_by_asc_lavel'] ) ? $filter_item['sort_by_asc_lavel'] : 'ASC'; |
|---|
| 1001 | $sort_by_desc_lavel = isset( $filter_item['sort_by_desc_lavel'] ) ? $filter_item['sort_by_desc_lavel'] : 'DESC'; |
|---|
| 1002 | ?> |
|---|
| 1003 | <div class="woolentor-filter-single-item woolentor-states-input-auto elementor-repeater-item-<?php echo esc_attr($filter_item['_id']); ?>"> |
|---|
| 1004 | <?php echo $filter_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
|---|
| 1005 | <select name="wl_sort" id="woolentor-field-for-<?php echo esc_attr($filter_item['_id']); ?>" class="woolentor-onchange-single-item woolentor-single-select-<?php echo esc_attr($id); ?>" data-minimum-results-for-search="Infinity" data-placeholder="<?php echo esc_attr($filter_item['wl_filter_placeholder']); ?>"> |
|---|
| 1006 | <?php |
|---|
| 1007 | if( !empty( $filter_item['wl_filter_placeholder'] ) ){echo '<option></option>';} |
|---|
| 1008 | ?> |
|---|
| 1009 | <option value="&wlsort=ASC" <?php selected( 'ASC', $wlsort, true ); ?> ><?php echo esc_html__( $sort_by_asc_lavel, 'woolentor' ); ?></option> |
|---|
| 1010 | <option value="&wlsort=DESC" <?php selected( 'DESC', $wlsort, true ); ?> ><?php echo esc_html__( $sort_by_desc_lavel, 'woolentor' ); ?></option> |
|---|
| 1011 | </select> |
|---|
| 1012 | </div> |
|---|
| 1013 | <?php |
|---|
| 1014 | |
|---|
| 1015 | }elseif( 'order_by' === $filter_item['wl_filter_type'] ){ |
|---|
| 1016 | $wlorder_by = ( isset( $_GET['wlorder_by'] ) && !empty( $_GET['wlorder_by'] ) ) ? $_GET['wlorder_by'] : ''; |
|---|
| 1017 | ?> |
|---|
| 1018 | <div class="woolentor-filter-single-item woolentor-states-input-auto elementor-repeater-item-<?php echo esc_attr($filter_item['_id']); ?>"> |
|---|
| 1019 | <?php echo $filter_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
|---|
| 1020 | <select name="wl_order_by_sort" id="woolentor-field-for-<?php echo esc_attr($filter_item['_id']); ?>" class="woolentor-onchange-single-item woolentor-single-select-<?php echo esc_attr($id); ?>" data-minimum-results-for-search="Infinity" data-placeholder="<?php echo esc_attr($filter_item['wl_filter_placeholder']); ?>"> |
|---|
| 1021 | <?php |
|---|
| 1022 | if( !empty( $filter_item['wl_filter_placeholder'] ) ){echo '<option></option>';} |
|---|
| 1023 | |
|---|
| 1024 | foreach ( woolentor_order_by_opts() as $key => $opt_data ) { |
|---|
| 1025 | echo '<option value="&wlorder_by='.esc_attr( $key ).'" '.selected( $key, $wlorder_by, false ).'>'.esc_html__( $opt_data, 'woolentor' ).'</option>'; |
|---|
| 1026 | } |
|---|
| 1027 | ?> |
|---|
| 1028 | </select> |
|---|
| 1029 | </div> |
|---|
| 1030 | <?php |
|---|
| 1031 | |
|---|
| 1032 | }elseif( 'price_by' === $filter_item['wl_filter_type'] ){ |
|---|
| 1033 | |
|---|
| 1034 | $woocommerce_currency_pos = get_option( 'woocommerce_currency_pos' ); |
|---|
| 1035 | $currency_pos_left = false; |
|---|
| 1036 | $currency_pos_space = false; |
|---|
| 1037 | if( $woocommerce_currency_pos == 'left' || $woocommerce_currency_pos == 'left_space' ){ |
|---|
| 1038 | $currency_pos_left = true; |
|---|
| 1039 | } |
|---|
| 1040 | |
|---|
| 1041 | if( strstr( $woocommerce_currency_pos, 'space' ) ){ |
|---|
| 1042 | $currency_pos_space = true; |
|---|
| 1043 | } |
|---|
| 1044 | |
|---|
| 1045 | if( $currency_pos_space == true && $currency_pos_left == true){ |
|---|
| 1046 | // left space |
|---|
| 1047 | $final_currency_symbol = $currency_symbol.' '; |
|---|
| 1048 | }else if( $currency_pos_space == true && $currency_pos_left == false ){ |
|---|
| 1049 | // right space |
|---|
| 1050 | $final_currency_symbol = ' '.$currency_symbol; |
|---|
| 1051 | }else{ |
|---|
| 1052 | $final_currency_symbol = $currency_symbol; |
|---|
| 1053 | } |
|---|
| 1054 | |
|---|
| 1055 | $cmin_price = ( isset( $_GET['min_price'] ) && !empty( $_GET['min_price'] ) ) ? $_GET['min_price'] : ''; |
|---|
| 1056 | $cmax_price = ( isset( $_GET['max_price'] ) && !empty( $_GET['max_price'] ) ) ? $_GET['max_price'] : ''; |
|---|
| 1057 | |
|---|
| 1058 | $current_price = [ $cmin_price, $cmax_price ]; |
|---|
| 1059 | |
|---|
| 1060 | $psl_placeholder = ''; |
|---|
| 1061 | if( empty( $cmin_price ) ){ |
|---|
| 1062 | $psl_placeholder = 'data-placeholder="'.esc_attr( !empty( $filter_item['wl_filter_placeholder'] ) ? $filter_item['wl_filter_placeholder'] : '' ).'"'; |
|---|
| 1063 | } |
|---|
| 1064 | |
|---|
| 1065 | $price_range_list = $settings['price_range_list']; |
|---|
| 1066 | |
|---|
| 1067 | if( isset( $price_range_list ) ): |
|---|
| 1068 | ?> |
|---|
| 1069 | <div class="woolentor-filter-single-item woolentor-states-input-auto elementor-repeater-item-<?php echo esc_attr($filter_item['_id']); ?>"> |
|---|
| 1070 | <?php echo $filter_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
|---|
| 1071 | <select id="woolentor-field-for-<?php echo esc_attr($filter_item['_id']); ?>" class="woolentor-onchange-single-item woolentor-price-filter woolentor-single-select-<?php echo esc_attr($id); ?>" data-minimum-results-for-search="Infinity" <?php echo $psl_placeholder; ?> > |
|---|
| 1072 | <?php |
|---|
| 1073 | if( !empty( $filter_item['wl_filter_placeholder'] ) && empty( $cmin_price ) ){echo '<option></option>';} |
|---|
| 1074 | |
|---|
| 1075 | foreach ( $price_range_list as $key => $price_range ) { |
|---|
| 1076 | |
|---|
| 1077 | $individual = [$price_range['min_price'], $price_range['max_price'] ]; |
|---|
| 1078 | $diff = array_diff( $individual, $current_price ); |
|---|
| 1079 | |
|---|
| 1080 | $pselected = 0; |
|---|
| 1081 | if( count( $diff ) == 0 ) { |
|---|
| 1082 | $pselected = 1; |
|---|
| 1083 | } |
|---|
| 1084 | |
|---|
| 1085 | if( $currency_pos_left ){ |
|---|
| 1086 | $generate_price = sprintf('%s%s %s %s%s',$final_currency_symbol,$price_range['min_price'], $price_range['price_seprator'],$final_currency_symbol,$price_range['max_price'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|---|
| 1087 | }else{ |
|---|
| 1088 | $generate_price = sprintf('%s%s %s %s%s',$price_range['min_price'], $final_currency_symbol, $price_range['price_seprator'],$price_range['max_price'], $final_currency_symbol ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|---|
| 1089 | } |
|---|
| 1090 | |
|---|
| 1091 | echo sprintf("<option value='%s' data-min_price='&min_price=%s' data-max_price='&max_price=%s' %s>%s</option>", $key, $price_range['min_price'], $price_range['max_price'], selected( $pselected, 1, false ), $generate_price ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|---|
| 1092 | } |
|---|
| 1093 | |
|---|
| 1094 | ?> |
|---|
| 1095 | </select> |
|---|
| 1096 | </div> |
|---|
| 1097 | <?php |
|---|
| 1098 | endif; |
|---|
| 1099 | |
|---|
| 1100 | }else{ |
|---|
| 1101 | $terms = get_terms( $filter_item['wl_filter_type'] ); |
|---|
| 1102 | if ( !empty( $terms ) && !is_wp_error( $terms )){ |
|---|
| 1103 | |
|---|
| 1104 | $taxonomy_data = get_taxonomy( $filter_item['wl_filter_type'] ); |
|---|
| 1105 | |
|---|
| 1106 | $filter_name = $filter_item['wl_filter_type']; |
|---|
| 1107 | $str = substr( $filter_item['wl_filter_type'], 0, 3 ); |
|---|
| 1108 | if( 'pa_' === $str ){ |
|---|
| 1109 | $filter_name = 'filter_' . wc_attribute_taxonomy_slug( $filter_item['wl_filter_type'] ); |
|---|
| 1110 | } |
|---|
| 1111 | |
|---|
| 1112 | if( $filter_name === 'product_cat' || $filter_name === 'product_tag' ){ |
|---|
| 1113 | $filter_name = 'woolentor_'.$filter_name; |
|---|
| 1114 | } |
|---|
| 1115 | |
|---|
| 1116 | $selected_taxonomies = ( isset( $_GET[$filter_name] ) && !empty( $_GET[$filter_name] ) ) ? explode( ',', $_GET[$filter_name] ) : array(); |
|---|
| 1117 | |
|---|
| 1118 | $sl_placeholder = ''; |
|---|
| 1119 | if( count( $selected_taxonomies ) != 1 ){ |
|---|
| 1120 | $sl_placeholder = 'data-placeholder="'.esc_attr( !empty( $filter_item['wl_filter_placeholder'] ) ? $filter_item['wl_filter_placeholder'] : $taxonomy_data->labels->singular_name ).'"'; |
|---|
| 1121 | } |
|---|
| 1122 | |
|---|
| 1123 | echo '<div class="woolentor-filter-single-item woolentor-states-input-auto elementor-repeater-item-'.esc_attr($filter_item['_id']).'">'; |
|---|
| 1124 | echo $filter_label; |
|---|
| 1125 | echo '<select name="wltaxonomies['.$filter_item['wl_filter_type'].'][]" class="woolentor-onchange-multiple-item woolentor-multiple-select-'.esc_attr($id).'" '.$sl_placeholder.' multiple="multiple">'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|---|
| 1126 | |
|---|
| 1127 | foreach ( $terms as $term ){ |
|---|
| 1128 | $link = $this->generate_term_link( $filter_item['wl_filter_type'], $term, null ); |
|---|
| 1129 | |
|---|
| 1130 | $selected = 0; |
|---|
| 1131 | if( in_array( $term->slug, $selected_taxonomies ) ) { |
|---|
| 1132 | $selected = 1; |
|---|
| 1133 | } |
|---|
| 1134 | |
|---|
| 1135 | echo sprintf('<option value="%1$s" %3$s>%2$s</option>', $link['link'], $term->name, selected( $selected, 1, false ) ); |
|---|
| 1136 | } |
|---|
| 1137 | |
|---|
| 1138 | echo '</select></div>'; |
|---|
| 1139 | |
|---|
| 1140 | } |
|---|
| 1141 | |
|---|
| 1142 | } |
|---|
| 1143 | |
|---|
| 1144 | } |
|---|
| 1145 | } |
|---|
| 1146 | ?> |
|---|
| 1147 | </div> |
|---|
| 1148 | <div class="woolentor-select-drop woolentor-single-select-drop-<?php echo esc_attr($id); ?>"></div> |
|---|
| 1149 | <div class="woolentor-select-drop woolentor-multiple-select-drop-<?php echo esc_attr($id); ?>"></div> |
|---|
| 1150 | </div> |
|---|
| 1151 | </div> |
|---|
| 1152 | </div> |
|---|
| 1153 | <!-- Heaer Box Area End --> |
|---|
| 1154 | </div> |
|---|
| 1155 | |
|---|
| 1156 | <script type="text/javascript"> |
|---|
| 1157 | ;jQuery(document).ready(function($) { |
|---|
| 1158 | 'use strict'; |
|---|
| 1159 | |
|---|
| 1160 | var id = '<?php echo esc_js($id); ?>', |
|---|
| 1161 | isEditorMode = '<?php echo woolentor_is_preview_mode(); ?>'; |
|---|
| 1162 | |
|---|
| 1163 | // Localize Text |
|---|
| 1164 | var selectTxt = '<?php echo esc_html__( 'select', 'woolentor' ); ?>', |
|---|
| 1165 | ofTxt = '<?php echo esc_html__( 'of', 'woolentor' ); ?>'; |
|---|
| 1166 | |
|---|
| 1167 | // Filter Toggle |
|---|
| 1168 | $('#filter-toggle-'+id).on('click', function(e){ |
|---|
| 1169 | e.preventDefault() |
|---|
| 1170 | $('#filter-item-'+id).slideToggle() |
|---|
| 1171 | }) |
|---|
| 1172 | |
|---|
| 1173 | |
|---|
| 1174 | $('.woolentor-single-select-'+id).select2({ |
|---|
| 1175 | dropdownParent: $('.woolentor-single-select-drop-'+id), |
|---|
| 1176 | }); |
|---|
| 1177 | $('.woolentor-multiple-select-'+id).select2({ |
|---|
| 1178 | // closeOnSelect : false, |
|---|
| 1179 | allowHtml: true, |
|---|
| 1180 | allowClear: true, |
|---|
| 1181 | dropdownParent: $('.woolentor-multiple-select-drop-'+id), |
|---|
| 1182 | }); |
|---|
| 1183 | |
|---|
| 1184 | $('.woolentor-filter-single-item select').on('change', function (e) { |
|---|
| 1185 | var output = $(this).siblings('span.select2').find('ul'); |
|---|
| 1186 | var total = e.currentTarget.length; |
|---|
| 1187 | var count = output.find('li').length - 0; |
|---|
| 1188 | if(count >= 3) { |
|---|
| 1189 | output.html("<li>"+count+" "+ofTxt+" "+total+" "+selectTxt+"</li>") |
|---|
| 1190 | } |
|---|
| 1191 | }); |
|---|
| 1192 | |
|---|
| 1193 | // Filter product |
|---|
| 1194 | var current_url = '<?php echo $current_url.'?wlfilter=1'; ?>'; |
|---|
| 1195 | $('.woolentor-filter-single-item select.woolentor-onchange-single-item').on('change', function () { |
|---|
| 1196 | var sort_key = $(this).val(); |
|---|
| 1197 | if ( sort_key && ( isEditorMode != true ) ) { |
|---|
| 1198 | window.location = current_url + sort_key; |
|---|
| 1199 | } |
|---|
| 1200 | return false; |
|---|
| 1201 | }); |
|---|
| 1202 | |
|---|
| 1203 | // Price Filter |
|---|
| 1204 | $('.woolentor-filter-single-item select.woolentor-price-filter').on( 'change', function(){ |
|---|
| 1205 | var selected = $(this).find('option:selected'), |
|---|
| 1206 | min_price = selected.data('min_price'), |
|---|
| 1207 | max_price = selected.data('max_price'), |
|---|
| 1208 | location = min_price + max_price; |
|---|
| 1209 | |
|---|
| 1210 | if ( location && ( isEditorMode != true ) ) { |
|---|
| 1211 | window.location = current_url + location; |
|---|
| 1212 | } |
|---|
| 1213 | |
|---|
| 1214 | }); |
|---|
| 1215 | |
|---|
| 1216 | // Texanomies Filter |
|---|
| 1217 | var previouslySelected = []; |
|---|
| 1218 | $('.woolentor-filter-single-item select.woolentor-onchange-multiple-item').on('change', function () { |
|---|
| 1219 | // Get newly selected elements |
|---|
| 1220 | var currentlySelected = $(this).val(); |
|---|
| 1221 | if( currentlySelected != null ){ |
|---|
| 1222 | |
|---|
| 1223 | if( currentlySelected.length == 0 && ( isEditorMode != true ) ){ |
|---|
| 1224 | window.location = current_url; |
|---|
| 1225 | }else{ |
|---|
| 1226 | var newSelections = currentlySelected.filter(function (element) { |
|---|
| 1227 | return previouslySelected.indexOf(element) == -1; |
|---|
| 1228 | }); |
|---|
| 1229 | previouslySelected = currentlySelected; |
|---|
| 1230 | if (newSelections.length) { |
|---|
| 1231 | // If there are multiple new selections, we'll take the last in the list |
|---|
| 1232 | var lastSelected = newSelections.reverse()[0]; |
|---|
| 1233 | } |
|---|
| 1234 | if ( lastSelected && ( isEditorMode != true ) ) { |
|---|
| 1235 | window.location = lastSelected; |
|---|
| 1236 | } |
|---|
| 1237 | } |
|---|
| 1238 | |
|---|
| 1239 | }else{ |
|---|
| 1240 | if(isEditorMode != true){ |
|---|
| 1241 | window.location = current_url; |
|---|
| 1242 | } |
|---|
| 1243 | } |
|---|
| 1244 | return false; |
|---|
| 1245 | }); |
|---|
| 1246 | |
|---|
| 1247 | |
|---|
| 1248 | }); |
|---|
| 1249 | </script> |
|---|
| 1250 | <?php |
|---|
| 1251 | } |
|---|
| 1252 | |
|---|
| 1253 | protected function generate_term_link( $filter_type, $term, $current_url ) { |
|---|
| 1254 | |
|---|
| 1255 | $filter_name = $filter_type; |
|---|
| 1256 | $str = substr( $filter_type, 0, 3 ); |
|---|
| 1257 | if( 'pa_' === $str ){ |
|---|
| 1258 | $filter_name = 'filter_' . wc_attribute_taxonomy_slug( $filter_type ); |
|---|
| 1259 | } |
|---|
| 1260 | |
|---|
| 1261 | if( $filter_name === 'product_cat' || $filter_name === 'product_tag' ){ |
|---|
| 1262 | $filter_name = 'woolentor_'.$filter_name; |
|---|
| 1263 | } |
|---|
| 1264 | |
|---|
| 1265 | $current_filter = isset( $_GET[ $filter_name ] ) ? explode( ',', wc_clean( wp_unslash( $_GET[ $filter_name ] ) ) ) : array(); |
|---|
| 1266 | $option_is_set = in_array( $term->slug, $current_filter, true ); |
|---|
| 1267 | |
|---|
| 1268 | // Generate choosen Class |
|---|
| 1269 | if( in_array( $term->slug, $current_filter ) ){ |
|---|
| 1270 | $active_class = 'wlchosen'; |
|---|
| 1271 | }else{ |
|---|
| 1272 | $active_class = ''; |
|---|
| 1273 | } |
|---|
| 1274 | |
|---|
| 1275 | // Term Link |
|---|
| 1276 | $current_filter = array_map( 'sanitize_title', $current_filter ); |
|---|
| 1277 | if ( ! in_array( $term->slug, $current_filter, true ) ) { |
|---|
| 1278 | $current_filter[] = $term->slug; |
|---|
| 1279 | } |
|---|
| 1280 | $link = remove_query_arg( $filter_name, $current_url ); |
|---|
| 1281 | |
|---|
| 1282 | foreach ( $current_filter as $key => $value ) { |
|---|
| 1283 | if ( $option_is_set && $value === $term->slug ) { |
|---|
| 1284 | unset( $current_filter[ $key ] ); |
|---|
| 1285 | } |
|---|
| 1286 | } |
|---|
| 1287 | |
|---|
| 1288 | if ( ! empty( $current_filter ) ) { |
|---|
| 1289 | asort( $current_filter ); |
|---|
| 1290 | $link = add_query_arg( 'wlfilter', '1', $link ); |
|---|
| 1291 | $link = add_query_arg( $filter_name, implode( ',', $current_filter ), $link ); |
|---|
| 1292 | |
|---|
| 1293 | $link = str_replace( '%2C', ',', $link ); |
|---|
| 1294 | } |
|---|
| 1295 | return [ |
|---|
| 1296 | 'link' => $link, |
|---|
| 1297 | 'class' => $active_class, |
|---|
| 1298 | ]; |
|---|
| 1299 | |
|---|
| 1300 | } |
|---|
| 1301 | |
|---|
| 1302 | |
|---|
| 1303 | } |
|---|