YITH WooCommerce Ajax Product Filter - Version 3.0.5

Version Description

  • Released: Jul 20, 2016 =

  • Fixed: style="displya:none"> text appears if the filters are empty

  • Fixed: Argument #1 is not an array in frontend class

  • Fixed: WP_Post object cannot convert to string in frontend class

  • Fixed: Problem with cirillic charachter

  • Fixed: Wrong count in filter widgets

Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Product Filter
Version 3.0.5
Comparing to
See all releases

Code changes from version 3.0.4 to 3.0.5

README.txt CHANGED
@@ -3,8 +3,8 @@
3
  Contributors: yithemes
4
  Tags: woocommerce ajax product filter download, woocommerce, widget, ajax, ajax filtered nav, ajax navigation, ajax filtered navigation, woocommerce layered navigation, woocommerce layered nav, product filter, product filters, ajax product filter, woocommerce ajax product filter, woocommerce filters, sidebar filter, sidebar ajax filter, ajax price filter, price filter, product sorting, woocommerce filter, taxonomy filter, attribute filter, attributes filter, woocommerce product sort, ajax sort, woocommerce ajax product filter, advanced product filters, ajax product filters, filters, woocommerce ajax product filters, woocommerce product filters, woocommerce product filters, category filter, attribute filters, woocommerce products filter, woocommerce price filter, yit, yith, yithemes
5
  Requires at least: 4.0
6
- Tested up to: 4.5.2
7
- Stable tag: 3.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -159,6 +159,14 @@ If you want to see a demonstration version of the premium plugin, you can see it
159
 
160
  == Changelog ==
161
 
 
 
 
 
 
 
 
 
162
  = 3.0.4 - Released: Jul 8, 2016 =
163
 
164
  * Fixed: Filters show all attributes in shop and product taxonomy pages
3
  Contributors: yithemes
4
  Tags: woocommerce ajax product filter download, woocommerce, widget, ajax, ajax filtered nav, ajax navigation, ajax filtered navigation, woocommerce layered navigation, woocommerce layered nav, product filter, product filters, ajax product filter, woocommerce ajax product filter, woocommerce filters, sidebar filter, sidebar ajax filter, ajax price filter, price filter, product sorting, woocommerce filter, taxonomy filter, attribute filter, attributes filter, woocommerce product sort, ajax sort, woocommerce ajax product filter, advanced product filters, ajax product filters, filters, woocommerce ajax product filters, woocommerce product filters, woocommerce product filters, category filter, attribute filters, woocommerce products filter, woocommerce price filter, yit, yith, yithemes
5
  Requires at least: 4.0
6
+ Tested up to: 4.5.3
7
+ Stable tag: 3.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
159
 
160
  == Changelog ==
161
 
162
+ = 3.0.5 - Released: Jul 20, 2016 =
163
+
164
+ * Fixed: style="displya:none"> text appears if the filters are empty
165
+ * Fixed: Argument #1 is not an array in frontend class
166
+ * Fixed: WP_Post object cannot convert to string in frontend class
167
+ * Fixed: Problem with cirillic charachter
168
+ * Fixed: Wrong count in filter widgets
169
+
170
  = 3.0.4 - Released: Jul 8, 2016 =
171
 
172
  * Fixed: Filters show all attributes in shop and product taxonomy pages
includes/class.yith-wcan-frontend.php CHANGED
@@ -133,8 +133,14 @@ if ( ! class_exists( 'YITH_WCAN_Frontend' ) ) {
133
  // Get main query
134
  $current_wp_query = $this->select_query_object( $query );
135
 
136
- // Get WP Query for current page (without 'paged')
137
- unset( $current_wp_query['paged'] );
 
 
 
 
 
 
138
 
139
  // Ensure filters are set
140
  $unfiltered_args = array_merge(
133
  // Get main query
134
  $current_wp_query = $this->select_query_object( $query );
135
 
136
+ if( is_array( $current_wp_query ) ){
137
+ // Get WP Query for current page (without 'paged')
138
+ unset( $current_wp_query['paged'] );
139
+ }
140
+
141
+ else {
142
+ $current_wp_query = array();
143
+ }
144
 
145
  // Ensure filters are set
146
  $unfiltered_args = array_merge(
includes/functions.yith-wcan.php CHANGED
@@ -472,7 +472,7 @@ if ( ! function_exists( 'yit_get_woocommerce_layered_nav_link' ) ) {
472
  */
473
  function yit_get_woocommerce_layered_nav_link() {
474
  $return = false;
475
- if ( defined( 'SHOP_IS_ON_FRONT' ) || ( is_shop() && ! is_product_category() ) ) {
476
  $taxonomy = get_query_var( 'taxonomy' );
477
  $brands_taxonomy = yit_get_brands_taxonomy();
478
  $return = get_post_type_archive_link( 'product' );
@@ -496,12 +496,13 @@ if ( ! function_exists( 'yit_get_woocommerce_layered_nav_link' ) ) {
496
  }
497
 
498
  else {
499
- $return = get_term_link( get_query_var( 'term' ), $taxonomy );
 
500
  }
501
-
502
  return apply_filters( 'yith_wcan_untrailingslashit', true ) && is_string( $return ) ? untrailingslashit( $return ) : $return;
503
  }
504
-
505
  return $return;
506
  }
507
  }
@@ -673,4 +674,30 @@ if( ! function_exists( 'yit_plus_character_hack' ) ) {
673
  function yit_plus_character_hack($link) {
674
  return $link = str_replace('+', '%2B', $link);
675
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
676
  }
472
  */
473
  function yit_get_woocommerce_layered_nav_link() {
474
  $return = false;
475
+ if ( defined( 'SHOP_IS_ON_FRONT' ) || ( is_shop() && ! is_product_category() ) ) {
476
  $taxonomy = get_query_var( 'taxonomy' );
477
  $brands_taxonomy = yit_get_brands_taxonomy();
478
  $return = get_post_type_archive_link( 'product' );
496
  }
497
 
498
  else {
499
+ $term = get_query_var( 'term' );
500
+ $return = get_term_link( yith_wcan_is_product_attribute() && is_numeric( $term ) ? intval( $term ) : $term, $taxonomy );
501
  }
502
+
503
  return apply_filters( 'yith_wcan_untrailingslashit', true ) && is_string( $return ) ? untrailingslashit( $return ) : $return;
504
  }
505
+
506
  return $return;
507
  }
508
  }
674
  function yit_plus_character_hack($link) {
675
  return $link = str_replace('+', '%2B', $link);
676
  }
677
+ }
678
+
679
+ if( ! function_exists( 'yit_in_array_ignore_case' ) ) {
680
+ /**
681
+ * Case insensitive version of in array function
682
+ *
683
+ * @return bool
684
+ *
685
+ * @since 2.8.6
686
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
687
+ */
688
+ function yit_in_array_ignore_case( $needle, $haystack ) {
689
+ return in_array(strtolower($needle), array_map('strtolower', $haystack));
690
+ }
691
+ }
692
+
693
+ if( !function_exists( 'yith_wcan_is_product_attribute' ) ) {
694
+ /**
695
+ * Return true when on an attribute archive page
696
+ *
697
+ * @param string $attribute
698
+ * @return bool
699
+ */
700
+ function yith_wcan_is_product_attribute( $attribute = '' ) {
701
+ return preg_match( '/pa_' . $attribute . '.*/', get_query_var( 'taxonomy' ) );
702
+ }
703
  }
init.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: YITH WooCommerce Ajax Product Filter
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Product Filter offers the perfect way to filter all the products of your shop.
6
- * Version: 3.0.4
7
  * Author: YITHEMES
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith-woocommerce-ajax-navigation
@@ -64,7 +64,7 @@ load_plugin_textdomain( 'yith-woocommerce-ajax-navigation', false, dirname( plug
64
  ! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
65
  ! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
66
  ! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
67
- ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '3.0.4' );
68
  ! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
69
  ! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
70
 
3
  * Plugin Name: YITH WooCommerce Ajax Product Filter
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Product Filter offers the perfect way to filter all the products of your shop.
6
+ * Version: 3.0.5
7
  * Author: YITHEMES
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith-woocommerce-ajax-navigation
64
  ! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
65
  ! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
66
  ! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
67
+ ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '3.0.5' );
68
  ! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
69
  ! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
70
 
widgets/class.yith-wcan-navigation-widget.php CHANGED
@@ -67,6 +67,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
67
  $is_parent_class = 'yit-wcan-parent-terms';
68
  $is_chosen_class = 'chosen';
69
  $terms_type_list = ( isset( $instance['display'] ) ) ? $instance['display'] : 'all';
 
70
 
71
  $instance['attribute'] = empty( $instance['attribute'] ) ? '' : $instance['attribute'];
72
  $instance['extra_class'] = empty( $instance['extra_class'] ) ? '' : $instance['extra_class'];
@@ -159,12 +160,12 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
159
  set_transient( $transient_name, $_products_in_term );
160
  //}
161
 
162
- $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) );
163
 
164
  // If this is an AND query, only show options with count > 0
165
  if ( $query_type == 'and' ) {
166
 
167
- $count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->filtered_product_ids ) );
168
 
169
  // skip the term for the current archive
170
  if ( $current_term == $term->$filter_term_field ) {
@@ -206,7 +207,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
206
 
207
  $current_filter = array_map( 'esc_attr', $current_filter );
208
 
209
- if ( ! in_array( $term->$filter_term_field, $current_filter ) ) {
210
  $current_filter[] = $term->$filter_term_field;
211
  }
212
 
@@ -218,7 +219,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
218
  if ( $name !== $taxonomy ) {
219
 
220
  // Exclude query arg for current term archive term
221
- while ( in_array( $current_term, $data['terms'] ) ) {
222
  $key = array_search( $current_term, $data );
223
  unset( $data['terms'][$key] );
224
  }
@@ -268,7 +269,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
268
  }
269
 
270
  // Current Filter = this widget
271
- if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
272
 
273
  $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
274
 
@@ -297,7 +298,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
297
  }
298
 
299
  // Query type Arg
300
- if ( $query_type == 'or' && ! ( sizeof( $current_filter ) == 1 && isset( $_chosen_attributes[$taxonomy]['terms'] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) ) {
301
  $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
302
  }
303
 
@@ -335,12 +336,12 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
335
  set_transient( $transient_name, $_products_in_term );
336
  //}
337
 
338
- $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) );
339
 
340
  // If this is an AND query, only show options with count > 0
341
  if ( $query_type == 'and' ) {
342
 
343
- $count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->filtered_product_ids ) );
344
 
345
  // skip the term for the current archive
346
  if ( $current_term == $term->$filter_term_field ) {
@@ -382,7 +383,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
382
 
383
  $current_filter = array_map( 'esc_attr', $current_filter );
384
 
385
- if ( ! in_array( $term->$filter_term_field, $current_filter ) ) {
386
  $current_filter[] = $term->$filter_term_field;
387
  }
388
 
@@ -394,7 +395,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
394
  if ( $name !== $taxonomy ) {
395
 
396
  // Exclude query arg for current term archive term
397
- while ( in_array( $current_term, $data['terms'] ) ) {
398
  $key = array_search( $current_term, $data );
399
  unset( $data['terms'][$key] );
400
  }
@@ -444,7 +445,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
444
  }
445
 
446
  // Current Filter = this widget
447
- if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
448
 
449
  $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
450
 
@@ -470,7 +471,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
470
  }
471
 
472
  // Query type Arg
473
- if ( $query_type == 'or' && ! ( sizeof( $current_filter ) == 1 && isset( $_chosen_attributes[$taxonomy]['terms'] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) ) {
474
  $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
475
  }
476
 
@@ -509,12 +510,12 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
509
  set_transient( $transient_name, $_products_in_term );
510
  //}
511
 
512
- $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) );
513
 
514
  // If this is an AND query, only show options with count > 0
515
  if ( $query_type == 'and' ) {
516
 
517
- $count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->filtered_product_ids ) );
518
 
519
  // skip the term for the current archive
520
  if ( $current_term == $term->$filter_term_field ) {
@@ -556,7 +557,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
556
 
557
  $current_filter = array_map( 'esc_attr', $current_filter );
558
 
559
- if ( ! in_array( $term->$filter_term_field, $current_filter ) ) {
560
  $current_filter[] = $term->$filter_term_field;
561
  }
562
 
@@ -568,7 +569,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
568
  if ( $name !== $taxonomy ) {
569
 
570
  // Exclude query arg for current term archive term
571
- while ( in_array( $current_term, $data['terms'] ) ) {
572
  $key = array_search( $current_term, $data );
573
  unset( $data['terms'][$key] );
574
  }
@@ -618,7 +619,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
618
  }
619
 
620
  // Current Filter = this widget
621
- if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
622
 
623
  $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
624
 
@@ -647,7 +648,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
647
  }
648
 
649
  // Query type Arg
650
- if ( $query_type == 'or' && ! ( sizeof( $current_filter ) == 1 && isset( $_chosen_attributes[$taxonomy]['terms'] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) ) {
651
  $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
652
  }
653
 
@@ -678,7 +679,6 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
678
 
679
  if ( ! $this->found ) {
680
  ob_end_clean();
681
- echo substr( $before_widget, 0, strlen( $before_widget ) - 1 ) . ' style="display:none">' . $after_widget;
682
  }
683
  else {
684
  echo ob_get_clean();
@@ -859,6 +859,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
859
 
860
  public function get_list_html( $terms, $taxonomy, $query_type, $display_type, $instance, $terms_type_list, $current_term, $args, $is_child_class, $is_parent_class, $is_chosen_class, $level = 0, $filter_term_field = 'slug' ){
861
  $_chosen_attributes = YITH_WCAN()->get_layered_nav_chosen_attributes();
 
862
  foreach ( $terms as $parent_id => $term_ids ) {
863
  $term = get_term_by( 'id', $parent_id, $taxonomy );
864
 
@@ -869,11 +870,11 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
869
  if( 'tags' == $instance['type'] ) {
870
  $term_id = yit_wcan_localize_terms( $term->term_id, $taxonomy );
871
  if ( 'exclude' == $instance['tags_list_query'] ){
872
- $echo = ! in_array( $term_id, $exclude );
873
  }
874
 
875
  elseif ( 'include' == $instance['tags_list_query'] ){
876
- $echo = in_array( $term_id, $include );
877
  }
878
  }
879
 
@@ -895,7 +896,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
895
  set_transient($transient_name, $_products_in_term);
896
  //}
897
 
898
- $option_is_set = (isset($_chosen_attributes[$taxonomy]) && in_array($term->term_id, $_chosen_attributes[$taxonomy]['terms']));
899
 
900
  $term_param = apply_filters('yith_wcan_term_param_uri', $term->$filter_term_field, $display_type, $term);
901
 
@@ -923,7 +924,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
923
 
924
  $current_filter = array_map('esc_attr', $current_filter);
925
 
926
- if (!in_array($term_param, $current_filter)) {
927
  $current_filter[] = $term_param;
928
  }
929
 
@@ -935,7 +936,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
935
  if ($name !== $taxonomy) {
936
 
937
  // Exclude query arg for current term archive
938
- while (in_array($term->slug, $data['terms'])) {
939
  $key = array_search($current_term, $data);
940
  unset($data['terms'][$key]);
941
  }
@@ -985,7 +986,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
985
  );
986
  }
987
 
988
- $check_for_current_widget = isset($_chosen_attributes[$taxonomy]) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms']);
989
  $class = '';
990
 
991
  // Current Filter = this widget
@@ -1041,7 +1042,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
1041
  $is_attribute = apply_filters('yith_wcan_is_attribute_check', true);
1042
 
1043
  // Query type Arg
1044
- if ($is_attribute && $query_type == 'or' && !(sizeof($current_filter) == 1 && isset($_chosen_attributes[$taxonomy]['terms']) && is_array($_chosen_attributes[$taxonomy]['terms']) && in_array($term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms']))) {
1045
  $link = add_query_arg('query_type_' . sanitize_title($instance['attribute']), 'or', $link);
1046
  }
1047
 
67
  $is_parent_class = 'yit-wcan-parent-terms';
68
  $is_chosen_class = 'chosen';
69
  $terms_type_list = ( isset( $instance['display'] ) ) ? $instance['display'] : 'all';
70
+ $in_array_function = apply_filters( 'yith_wcan_in_array_ignor_case', false ) ? 'yit_in_array_ignore_case' : 'in_array';
71
 
72
  $instance['attribute'] = empty( $instance['attribute'] ) ? '' : $instance['attribute'];
73
  $instance['extra_class'] = empty( $instance['extra_class'] ) ? '' : $instance['extra_class'];
160
  set_transient( $transient_name, $_products_in_term );
161
  //}
162
 
163
+ $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) );
164
 
165
  // If this is an AND query, only show options with count > 0
166
  if ( $query_type == 'and' ) {
167
 
168
+ $count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
169
 
170
  // skip the term for the current archive
171
  if ( $current_term == $term->$filter_term_field ) {
207
 
208
  $current_filter = array_map( 'esc_attr', $current_filter );
209
 
210
+ if ( ! $in_array_function( $term->$filter_term_field, $current_filter ) ) {
211
  $current_filter[] = $term->$filter_term_field;
212
  }
213
 
219
  if ( $name !== $taxonomy ) {
220
 
221
  // Exclude query arg for current term archive term
222
+ while ( $in_array_function( $current_term, $data['terms'] ) ) {
223
  $key = array_search( $current_term, $data );
224
  unset( $data['terms'][$key] );
225
  }
269
  }
270
 
271
  // Current Filter = this widget
272
+ if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
273
 
274
  $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
275
 
298
  }
299
 
300
  // Query type Arg
301
+ if ( $query_type == 'or' && ! ( sizeof( $current_filter ) == 1 && isset( $_chosen_attributes[$taxonomy]['terms'] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) ) {
302
  $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
303
  }
304
 
336
  set_transient( $transient_name, $_products_in_term );
337
  //}
338
 
339
+ $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) );
340
 
341
  // If this is an AND query, only show options with count > 0
342
  if ( $query_type == 'and' ) {
343
 
344
+ $count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
345
 
346
  // skip the term for the current archive
347
  if ( $current_term == $term->$filter_term_field ) {
383
 
384
  $current_filter = array_map( 'esc_attr', $current_filter );
385
 
386
+ if ( ! $in_array_function( $term->$filter_term_field, $current_filter ) ) {
387
  $current_filter[] = $term->$filter_term_field;
388
  }
389
 
395
  if ( $name !== $taxonomy ) {
396
 
397
  // Exclude query arg for current term archive term
398
+ while ( $in_array_function( $current_term, $data['terms'] ) ) {
399
  $key = array_search( $current_term, $data );
400
  unset( $data['terms'][$key] );
401
  }
445
  }
446
 
447
  // Current Filter = this widget
448
+ if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
449
 
450
  $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
451
 
471
  }
472
 
473
  // Query type Arg
474
+ if ( $query_type == 'or' && ! ( sizeof( $current_filter ) == 1 && isset( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) ) {
475
  $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
476
  }
477
 
510
  set_transient( $transient_name, $_products_in_term );
511
  //}
512
 
513
+ $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) );
514
 
515
  // If this is an AND query, only show options with count > 0
516
  if ( $query_type == 'and' ) {
517
 
518
+ $count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
519
 
520
  // skip the term for the current archive
521
  if ( $current_term == $term->$filter_term_field ) {
557
 
558
  $current_filter = array_map( 'esc_attr', $current_filter );
559
 
560
+ if ( ! $in_array_function( $term->$filter_term_field, $current_filter ) ) {
561
  $current_filter[] = $term->$filter_term_field;
562
  }
563
 
569
  if ( $name !== $taxonomy ) {
570
 
571
  // Exclude query arg for current term archive term
572
+ while ( $in_array_function( $current_term, $data['terms'] ) ) {
573
  $key = array_search( $current_term, $data );
574
  unset( $data['terms'][$key] );
575
  }
619
  }
620
 
621
  // Current Filter = this widget
622
+ if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
623
 
624
  $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
625
 
648
  }
649
 
650
  // Query type Arg
651
+ if ( $query_type == 'or' && ! ( sizeof( $current_filter ) == 1 && isset( $_chosen_attributes[$taxonomy]['terms'] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) ) {
652
  $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
653
  }
654
 
679
 
680
  if ( ! $this->found ) {
681
  ob_end_clean();
 
682
  }
683
  else {
684
  echo ob_get_clean();
859
 
860
  public function get_list_html( $terms, $taxonomy, $query_type, $display_type, $instance, $terms_type_list, $current_term, $args, $is_child_class, $is_parent_class, $is_chosen_class, $level = 0, $filter_term_field = 'slug' ){
861
  $_chosen_attributes = YITH_WCAN()->get_layered_nav_chosen_attributes();
862
+ $in_array_function = apply_filters( 'yith_wcan_in_array_ignor_case', false ) ? 'yit_in_array_ignore_case' : 'in_array';
863
  foreach ( $terms as $parent_id => $term_ids ) {
864
  $term = get_term_by( 'id', $parent_id, $taxonomy );
865
 
870
  if( 'tags' == $instance['type'] ) {
871
  $term_id = yit_wcan_localize_terms( $term->term_id, $taxonomy );
872
  if ( 'exclude' == $instance['tags_list_query'] ){
873
+ $echo = ! $in_array_function( $term_id, $exclude );
874
  }
875
 
876
  elseif ( 'include' == $instance['tags_list_query'] ){
877
+ $echo = $in_array_function( $term_id, $include );
878
  }
879
  }
880
 
896
  set_transient($transient_name, $_products_in_term);
897
  //}
898
 
899
+ $option_is_set = (isset($_chosen_attributes[$taxonomy]) && $in_array_function($term->term_id, $_chosen_attributes[$taxonomy]['terms']));
900
 
901
  $term_param = apply_filters('yith_wcan_term_param_uri', $term->$filter_term_field, $display_type, $term);
902
 
924
 
925
  $current_filter = array_map('esc_attr', $current_filter);
926
 
927
+ if ( ! $in_array_function( $term_param, $current_filter ) ) {
928
  $current_filter[] = $term_param;
929
  }
930
 
936
  if ($name !== $taxonomy) {
937
 
938
  // Exclude query arg for current term archive
939
+ while ($in_array_function($term->slug, $data['terms'])) {
940
  $key = array_search($current_term, $data);
941
  unset($data['terms'][$key]);
942
  }
986
  );
987
  }
988
 
989
+ $check_for_current_widget = isset($_chosen_attributes[$taxonomy]) && is_array($_chosen_attributes[$taxonomy]['terms']) && $in_array_function($term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms']);
990
  $class = '';
991
 
992
  // Current Filter = this widget
1042
  $is_attribute = apply_filters('yith_wcan_is_attribute_check', true);
1043
 
1044
  // Query type Arg
1045
+ if ($is_attribute && $query_type == 'or' && !(sizeof($current_filter) == 1 && isset($_chosen_attributes[$taxonomy]['terms']) && is_array($_chosen_attributes[$taxonomy]['terms']) && $in_array_function($term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms']))) {
1046
  $link = add_query_arg('query_type_' . sanitize_title($instance['attribute']), 'or', $link);
1047
  }
1048
 
widgets/class.yith-wcan-reset-navigation-widget.php CHANGED
@@ -81,7 +81,6 @@ if ( ! class_exists( 'YITH_WCAN_Reset_Navigation_Widget' ) ) {
81
  }
82
  else {
83
  ob_end_clean();
84
- echo substr( $before_widget, 0, strlen( $before_widget ) - 1 ) . ' style="display:none">' . $after_widget;
85
  }
86
  }
87
 
81
  }
82
  else {
83
  ob_end_clean();
 
84
  }
85
  }
86