YITH WooCommerce Ajax Product Filter - Version 2.7.2

Version Description

  • Added: Support to WooCommerce 2.5-RC1
  • Fixed: Reset Filter in category page
  • Fixed: Filter doesn't work correctly in sub-categories
Download this release

Release Info

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

Code changes from version 2.7.1 to 2.7.2

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.4
7
- Stable tag: 2.7.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -159,6 +159,12 @@ If you want to see a demonstration version of the premium plugin, you can see it
159
160
== Changelog ==
161
162
= 2.7.1 =
163
164
* Fixed: The plugin shows empty filters in product category page
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.4.1
7
+ Stable tag: 2.7.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
159
160
== Changelog ==
161
162
+ = 2.7.2 =
163
+
164
+ * Added: Support to WooCommerce 2.5-RC1
165
+ * Fixed: Reset Filter in category page
166
+ * Fixed: Filter doesn't work correctly in sub-categories
167
+
168
= 2.7.1 =
169
170
* Fixed: The plugin shows empty filters in product category page
assets/css/frontend.css CHANGED
@@ -277,3 +277,42 @@ a.yith-wcan-price-link.active:before {
277
}
278
279
277
}
278
279
280
+ /*--------------------------
281
+ CHECKBOX LAYOUT
282
+ ---------------------------*/
283
+ .yith-woocommerce-ajax-product-filter.with-checkbox{
284
+
285
+ }
286
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul{
287
+ list-style-type: none;
288
+ padding-left: 0;
289
+ }
290
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li a:before{
291
+ content: '';
292
+ display: inline-block;
293
+ background-image: url("../images/checkbox_sprite.png");
294
+ background-repeat: no-repeat;
295
+ background-position: top center;
296
+ width: 11px;
297
+ height: 11px;
298
+ margin-right: 5px;
299
+ }
300
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li a.active:before,
301
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li a.chosen:before,
302
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li.active a:before,
303
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li.chosen a:before,
304
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul.orderby li a.active:before,
305
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul.orderby li a.chosen:before,
306
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul.orderby li.active a:before,
307
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul.orderby li.chosen a:before{
308
+ content: '';
309
+ background-position: bottom center;
310
+ }
311
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li a:after,
312
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li a.active:after,
313
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li a.chosen:after,
314
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li.active a:after,
315
+ .yith-woocommerce-ajax-product-filter.with-checkbox ul li.chosen a:after{
316
+ content: '';
317
+ display: none;
318
+ }
includes/functions.yith-wcan.php CHANGED
@@ -191,6 +191,10 @@ if ( ! function_exists( 'yit_reorder_terms_by_parent' ) ) {
191
$terms_count ++;
192
}
193
194
/* Reorder Therms */
195
$terms_count = 0;
196
$terms = array();
@@ -202,6 +206,10 @@ if ( ! function_exists( 'yit_reorder_terms_by_parent' ) ) {
202
/* The term as child */
203
if ( array_key_exists( $term->term_id, $child_terms ) ) {
204
205
foreach ( $child_terms[$term->term_id] as $child_term ) {
206
$terms_count ++;
207
$terms[$terms_count] = $child_term;
@@ -228,6 +236,7 @@ if ( ! function_exists( 'yit_get_terms' ) ) {
228
229
$exclude = apply_filters( 'yith_wcan_exclude_terms', array(), $instance );
230
$include = apply_filters( 'yith_wcan_include_terms', array(), $instance );
231
232
switch ( $case ) {
233
@@ -236,7 +245,11 @@ if ( ! function_exists( 'yit_get_terms' ) ) {
236
break;
237
238
case 'hierarchical':
239
- $terms = yit_reorder_terms_by_parent( get_terms( $taxonomy, array( 'hide_empty' => true, 'exclude' => $exclude ) ) );
240
break;
241
242
case 'parent' :
@@ -252,12 +265,19 @@ if ( ! function_exists( 'yit_get_terms' ) ) {
252
$terms = get_terms( $taxonomy, $args );
253
254
if ( 'hierarchical' == $instance['display'] ) {
255
- $terms = yit_reorder_terms_by_parent( $terms );
256
}
257
break;
258
}
259
260
- return $terms;
261
}
262
}
263
@@ -500,4 +520,20 @@ if ( ! function_exists( 'yit_wcan_get_product_taxonomy' ) ) {
500
return array_merge( $product_taxonomies, apply_filters( 'yith_wcan_product_taxonomy_type', array() ) );
501
}
502
503
}
191
$terms_count ++;
192
}
193
194
+ if( 'product' == yith_wcan_get_option( 'yith_wcan_ajax_shop_terms_order', 'alphabetical' ) && ! is_wp_error( $parent_terms ) ){
195
+ usort( $parent_terms, 'yit_terms_sort' );
196
+ }
197
+
198
/* Reorder Therms */
199
$terms_count = 0;
200
$terms = array();
206
/* The term as child */
207
if ( array_key_exists( $term->term_id, $child_terms ) ) {
208
209
+ if( 'product' == yith_wcan_get_option( 'yith_wcan_ajax_shop_terms_order', 'alphabetical' ) && ! is_wp_error( $child_terms[$term->term_id] ) ){
210
+ usort( $child_terms[$term->term_id], 'yit_terms_sort' );
211
+ }
212
+
213
foreach ( $child_terms[$term->term_id] as $child_term ) {
214
$terms_count ++;
215
$terms[$terms_count] = $child_term;
236
237
$exclude = apply_filters( 'yith_wcan_exclude_terms', array(), $instance );
238
$include = apply_filters( 'yith_wcan_include_terms', array(), $instance );
239
+ $reordered = false;
240
241
switch ( $case ) {
242
245
break;
246
247
case 'hierarchical':
248
+ $terms = get_terms( $taxonomy, array( 'hide_empty' => true, 'exclude' => $exclude ) );
249
+ if( ! in_array( $instance['type'], apply_filters( 'yith_wcan_display_type_list', array( 'list' ) ) ) ) {
250
+ $terms = yit_reorder_terms_by_parent( $terms );
251
+ $reordered = true;
252
+ }
253
break;
254
255
case 'parent' :
265
$terms = get_terms( $taxonomy, $args );
266
267
if ( 'hierarchical' == $instance['display'] ) {
268
+ if( ! in_array( $instance['type'], apply_filters( 'yith_wcan_display_type_list', array( 'list' ) ) ) ) {
269
+ $terms = yit_reorder_terms_by_parent( $terms );
270
+ $reordered = true;
271
+ }
272
}
273
break;
274
}
275
276
+ if( 'product' == yith_wcan_get_option( 'yith_wcan_ajax_shop_terms_order', 'alphabetical' ) && 'hierarchical' != $instance['display'] && ! is_wp_error( $terms ) && ! $reordered ){
277
+ usort( $terms, 'yit_terms_sort' );
278
+ }
279
+
280
+ return apply_filters( 'yith_wcan_get_terms_list', $terms, $taxonomy, $instance );
281
}
282
}
283
520
return array_merge( $product_taxonomies, apply_filters( 'yith_wcan_product_taxonomy_type', array() ) );
521
}
522
523
+ }
524
+
525
+ if( ! function_exists( 'yit_terms_sort' ) ){
526
+
527
+ function yit_terms_sort( $a, $b ){
528
+ $result = 0;
529
+ if ( $a->count < $b->count ) {
530
+ $result = 1;
531
+ }
532
+
533
+ elseif ( $a->count > $b->count ) {
534
+ $result = - 1;
535
+ }
536
+ return $result;
537
+ }
538
+
539
}
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: 2.7.1
7
* Author: yithemes
8
* Author URI: http://yithemes.com/
9
* Text Domain: yith_wc_ajxnav
@@ -65,7 +65,7 @@ if ( defined( 'YITH_WCAN_VERSION' ) ) {
65
! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
66
! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
67
! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
68
- ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '2.7.1' );
69
! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
70
! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
71
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: 2.7.2
7
* Author: yithemes
8
* Author URI: http://yithemes.com/
9
* Text Domain: yith_wc_ajxnav
65
! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
66
! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
67
! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
68
+ ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '2.7.2' );
69
! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
70
! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
71
plugin-fw/lib/yit-plugin-panel.php CHANGED
@@ -147,7 +147,8 @@ if ( ! class_exists( 'YIT_Plugin_Panel' ) ) {
147
wp_enqueue_style( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css' );
148
wp_enqueue_style( 'yit-jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.css', array(), $jquery_version );
149
150
- if( 'admin.php' == $pagenow && strpos('yit-plugins_page',get_current_screen()->id ) !== false ){
151
wp_enqueue_style( 'yit-plugin-style' );
152
wp_enqueue_script( 'yit-plugin-panel' );
153
}
147
wp_enqueue_style( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css' );
148
wp_enqueue_style( 'yit-jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.css', array(), $jquery_version );
149
150
+
151
+ if( 'admin.php' == $pagenow && strpos( get_current_screen()->id, 'yit-plugins_page' ) !== false ){
152
wp_enqueue_style( 'yit-plugin-style' );
153
wp_enqueue_script( 'yit-plugin-panel' );
154
}
widgets/class.yith-wcan-navigation-widget.php CHANGED
@@ -31,7 +31,9 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
31
public $found = false;
32
33
function __construct() {
34
- $widget_ops = array( 'classname' => 'yith-woo-ajax-navigation woocommerce widget_layered_nav', 'description' => __( 'Filter the product list without reloading the page', 'yith-woocommerce-ajax-navigation' ) );
35
$control_ops = array( 'width' => 400, 'height' => 350 );
36
add_action('wp_ajax_yith_wcan_select_type', array( $this, 'ajax_print_terms') );
37
parent::__construct( 'yith-woo-ajax-navigation', _x( 'YITH WooCommerce Ajax Product Filter', 'Admin: Widget Title', 'yith-woocommerce-ajax-navigation' ), $widget_ops, $control_ops );
@@ -75,17 +77,16 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
75
$taxonomy = $woocommerce->attribute_taxonomy_name( $instance['attribute'] );
76
}
77
78
if ( ! taxonomy_exists( $taxonomy ) ) {
79
return;
80
}
81
82
- $taxonomy = apply_filters( 'yith_wcan_get_terms_params', $taxonomy, $instance, 'taxonomy_name' );
83
- $terms_type_list = apply_filters( 'yith_wcan_get_terms_params', $terms_type_list, $instance, 'terms_type' );
84
-
85
$terms = yit_get_terms( $terms_type_list, $taxonomy, $instance );
86
87
if ( count( $terms ) > 0 ) {
88
-
89
ob_start();
90
91
$this->found = false;
@@ -255,7 +256,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
255
}
256
257
else {
258
- $class = ( ( $terms_type_list == 'hierarchical' || ( $terms_type_list == 'tags' && $instance['display'] == 'hierarchical' ) ) && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
259
$link = add_query_arg( $arg, implode( apply_filters( 'yith_wcan_list_filter_operator', ',', $display_type ), $current_filter ), $link );
260
}
261
31
public $found = false;
32
33
function __construct() {
34
+ $classname = 'yith-woocommerce-ajax-product-filter yith-woo-ajax-navigation woocommerce widget_layered_nav';
35
+ $classname .= 'checkboxes' == yith_wcan_get_option( 'yith_wcan_ajax_shop_filter_style', 'standard' ) ? ' with-checkbox' : '';
36
+ $widget_ops = array( 'classname' => $classname, 'description' => __( 'Filter the product list without reloading the page', 'yith-woocommerce-ajax-navigation' ) );
37
$control_ops = array( 'width' => 400, 'height' => 350 );
38
add_action('wp_ajax_yith_wcan_select_type', array( $this, 'ajax_print_terms') );
39
parent::__construct( 'yith-woo-ajax-navigation', _x( 'YITH WooCommerce Ajax Product Filter', 'Admin: Widget Title', 'yith-woocommerce-ajax-navigation' ), $widget_ops, $control_ops );
77
$taxonomy = $woocommerce->attribute_taxonomy_name( $instance['attribute'] );
78
}
79
80
+ $taxonomy = apply_filters( 'yith_wcan_get_terms_params', $taxonomy, $instance, 'taxonomy_name' );
81
+ $terms_type_list = apply_filters( 'yith_wcan_get_terms_params', $terms_type_list, $instance, 'terms_type' );
82
+
83
if ( ! taxonomy_exists( $taxonomy ) ) {
84
return;
85
}
86
87
$terms = yit_get_terms( $terms_type_list, $taxonomy, $instance );
88
89
if ( count( $terms ) > 0 ) {
90
ob_start();
91
92
$this->found = false;
256
}
257
258
else {
259
+ $class = ( ( $terms_type_list == 'hierarchical' || $terms_type_list == 'tags' ) && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
260
$link = add_query_arg( $arg, implode( apply_filters( 'yith_wcan_list_filter_operator', ',', $display_type ), $current_filter ), $link );
261
}
262
widgets/class.yith-wcan-reset-navigation-widget.php CHANGED
@@ -20,7 +20,7 @@ if ( ! class_exists( 'YITH_WCAN_Reset_Navigation_Widget' ) ) {
20
class YITH_WCAN_Reset_Navigation_Widget extends WP_Widget {
21
22
function __construct() {
23
- $widget_ops = array( 'classname' => 'yith-woo-ajax-reset-navigation yith-woo-ajax-navigation woocommerce widget_layered_nav', 'description' => __( 'Reset all filters set by YITH WooCommerce Ajax Product Filter', 'yith-woocommerce-ajax-navigation' ) );
24
$control_ops = array( 'width' => 400, 'height' => 350 );
25
parent::__construct( 'yith-woo-ajax-reset-navigation', __( 'YITH WooCommerce Ajax Reset Filter', 'yith-woocommerce-ajax-navigation' ), $widget_ops, $control_ops );
26
}
@@ -47,14 +47,25 @@ if ( ! class_exists( 'YITH_WCAN_Reset_Navigation_Widget' ) ) {
47
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : '';
48
$label = isset( $instance['label'] ) ? apply_filters( 'yith-wcan-reset-navigation-label', $instance['label'], $instance, $this->id_base ) : '';
49
50
//clean the url
51
- $link = yit_curPageURL();
52
- foreach ( (array) $_chosen_attributes as $taxonomy => $data ) {
53
- $taxonomy_filter = str_replace( 'pa_', '', $taxonomy );
54
- $link = remove_query_arg( 'filter_' . $taxonomy_filter, $link );
55
}
56
57
- $link = remove_query_arg( array( 'min_price', 'max_price', 'product_tag' ), $link );
58
59
$link = apply_filters( 'yith_woocommerce_reset_filter_link', $link );
60
20
class YITH_WCAN_Reset_Navigation_Widget extends WP_Widget {
21
22
function __construct() {
23
+ $widget_ops = array( 'classname' => 'yith-woocommerce-ajax-product-filter yith-woo-ajax-reset-navigation yith-woo-ajax-navigation woocommerce widget_layered_nav', 'description' => __( 'Reset all filters set by YITH WooCommerce Ajax Product Filter', 'yith-woocommerce-ajax-navigation' ) );
24
$control_ops = array( 'width' => 400, 'height' => 350 );
25
parent::__construct( 'yith-woo-ajax-reset-navigation', __( 'YITH WooCommerce Ajax Reset Filter', 'yith-woocommerce-ajax-navigation' ), $widget_ops, $control_ops );
26
}
47
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : '';
48
$label = isset( $instance['label'] ) ? apply_filters( 'yith-wcan-reset-navigation-label', $instance['label'], $instance, $this->id_base ) : '';
49
50
+ $link = '';
51
+
52
//clean the url
53
+ if( ! isset( $_GET['source_id'] ) ){
54
+ $link = yit_curPageURL();
55
+ foreach ( (array) $_chosen_attributes as $taxonomy => $data ) {
56
+ $taxonomy_filter = str_replace( 'pa_', '', $taxonomy );
57
+ $link = remove_query_arg( 'filter_' . $taxonomy_filter, $link );
58
+ }
59
+
60
+ $link = remove_query_arg( array( 'min_price', 'max_price', 'product_tag' ), $link );
61
+ }
62
+
63
+ else{
64
+ //Start filter from Product category Page
65
+ $term = get_term_by( 'id', $_GET['source_id'], 'product_cat' );
66
+ $link = get_term_link( $term, $term->taxonomy );
67
}
68
69
70
$link = apply_filters( 'yith_woocommerce_reset_filter_link', $link );
71