Version Description
Released: 20 February, 2017 =
Add: Back/Next browser button integration
Tweak: Filter uri management
Tweak: Add filter to force widget dropdown reinit
Tweak: YITH Brands integration
Fix: Unable to hide product count for attributes
Fix: Lost brands on 2nd filter step
Fix: Current filter disappears in label, dropdown and color style
Fix: Filter by attribute (all styles) lost current category in product category page
Fix: Missing queried object in filter type list
Fix: Conflict in search page
Dev: yith_wcan_unfiltered_product_ids hook
Download this release
Release Info
Developer | yithemes |
Plugin | YITH WooCommerce Ajax Product Filter |
Version | 3.2.0 |
Comparing to | |
See all releases |
Code changes from version 3.1.2 to 3.2.0
- README.txt +18 -3
- assets/css/frontend.css +1 -0
- assets/js/yith-wcan-frontend.js +3 -0
- assets/js/yith-wcan-frontend.min.js +1 -1
- includes/class.yith-wcan-frontend.php +1 -1
- includes/functions.yith-wcan.php +55 -24
- init.php +2 -2
- plugin-fw/lib/yit-plugin-panel.php +1 -1
- plugin-fw/licence/lib/yit-licence.php +3 -2
- plugin-fw/yit-plugin.php +1 -0
- plugin-fw/yit-woocommerce-compatibility.php +408 -0
- screenshot-1.png +0 -0
- screenshot-10.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
- screenshot-7.png +0 -0
- screenshot-8.png +0 -0
- screenshot-9.png +0 -0
- widgets/class.yith-wcan-navigation-widget.php +140 -31
- widgets/class.yith-wcan-reset-navigation-widget.php +1 -1
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.7
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -143,7 +143,7 @@ You can get more features with the premium version of YITH WooCommerce Ajax Prod
|
|
143 |
= How can I try the full-featured plugin? =
|
144 |
|
145 |
If you want to see a demonstration version of the premium plugin, you can see it installed on two different WooCommerce sites, either in [this page]( http://plugins.yithemes.com/yith-woocommerce-ajax-product-filter/?preview) or in [this page](http://preview.yithemes.com/bazar/shop/). Browse it and try all options available so that you can see how your plugin looks like.
|
146 |
-
|
147 |
== Screenshots ==
|
148 |
|
149 |
1. Admin - Appearance -> Widget: WooCommerce Filter Widget List Style
|
@@ -159,6 +159,21 @@ If you want to see a demonstration version of the premium plugin, you can see it
|
|
159 |
|
160 |
== Changelog ==
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
= 3.1.2 - Released: 17 January, 2017 =
|
163 |
|
164 |
* Tweak: Support for YITH WooCommerce Brands add-on FREE
|
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.7.2
|
7 |
+
Stable tag: 3.2.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
143 |
= How can I try the full-featured plugin? =
|
144 |
|
145 |
If you want to see a demonstration version of the premium plugin, you can see it installed on two different WooCommerce sites, either in [this page]( http://plugins.yithemes.com/yith-woocommerce-ajax-product-filter/?preview) or in [this page](http://preview.yithemes.com/bazar/shop/). Browse it and try all options available so that you can see how your plugin looks like.
|
146 |
+
|
147 |
== Screenshots ==
|
148 |
|
149 |
1. Admin - Appearance -> Widget: WooCommerce Filter Widget List Style
|
159 |
|
160 |
== Changelog ==
|
161 |
|
162 |
+
= 3.2.0 - Released: 20 February, 2017 =
|
163 |
+
|
164 |
+
* Add: Back/Next browser button integration
|
165 |
+
* Tweak: Filter uri management
|
166 |
+
* Tweak: Add filter to force widget dropdown reinit
|
167 |
+
* Tweak: YITH Brands integration
|
168 |
+
* Fix: Unable to hide product count for attributes
|
169 |
+
* Fix: Lost brands on 2nd filter step
|
170 |
+
* Fix: Current filter disappears in label, dropdown and color style
|
171 |
+
* Fix: Filter by attribute (all styles) lost current category in product category page
|
172 |
+
* Fix: Missing queried object in filter type list
|
173 |
+
* Fix: Conflict in search page
|
174 |
+
* Dev: yith_wcan_unfiltered_product_ids hook
|
175 |
+
|
176 |
+
|
177 |
= 3.1.2 - Released: 17 January, 2017 =
|
178 |
|
179 |
* Tweak: Support for YITH WooCommerce Brands add-on FREE
|
assets/css/frontend.css
CHANGED
@@ -302,6 +302,7 @@ a.yith-wcan-price-link.active:before {
|
|
302 |
.yith-woocommerce-ajax-product-filter.with-checkbox ul{
|
303 |
list-style-type: none;
|
304 |
padding-left: 0;
|
|
|
305 |
}
|
306 |
.yith-woocommerce-ajax-product-filter.yith-wcan-sort-by.with-checkbox ul{
|
307 |
margin-left: 0;
|
302 |
.yith-woocommerce-ajax-product-filter.with-checkbox ul{
|
303 |
list-style-type: none;
|
304 |
padding-left: 0;
|
305 |
+
margin-left: 0;
|
306 |
}
|
307 |
.yith-woocommerce-ajax-product-filter.yith-wcan-sort-by.with-checkbox ul{
|
308 |
margin-left: 0;
|
assets/js/yith-wcan-frontend.js
CHANGED
@@ -408,4 +408,7 @@ jQuery(function ($) {
|
|
408 |
});
|
409 |
});
|
410 |
}
|
|
|
|
|
|
|
411 |
});
|
408 |
});
|
409 |
});
|
410 |
}
|
411 |
+
|
412 |
+
/* Browser History Back/Prev Button */
|
413 |
+
window.addEventListener('popstate', function (e) { window.location.reload(true); });
|
414 |
});
|
assets/js/yith-wcan-frontend.min.js
CHANGED
@@ -13,4 +13,4 @@ jQuery(function(a){function u(a,p){return a.replace(new RegExp("[?&]"+p+"=[^&#]*
|
|
13 |
[e,f])}a(document).trigger("yith-wcan-ajax-reset-filtered")}x()}})};a(yith_wcan.container).not(".ywcps-products").wrap('<div class="yit-wcan-container"></div>');a(document).on("yith-wcan-wrapped",function(){x()});a(document).trigger("yith-wcan-wrapped");a(document).on("click",".yith-wcan a",function(h){a(this).yith_wcan_ajax_filters(h,this)});var t=function(){a("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",opacity:0},0);a("a.yit-wcan-select-open").removeClass("active")};
|
14 |
a(document).on("click","a.yit-wcan-select-open.active",function(h){h.preventDefault();a(this).parent().find("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",opacity:0},300);a(this).parent().find("a.yit-wcan-select-open").removeClass("active")});a(document).on("click","a.yit-wcan-select-open:not(.active)",function(h){h.preventDefault();a("a.yit-wcan-select-open.active").trigger("click");a(this).parent().find("div.yith-wcan-select-wrapper").css("z-index","1").animate({visibility:"visible",
|
15 |
opacity:1},300);a(this).parent().find("a.yit-wcan-select-open").addClass("active")});a(document).on("ready yith-wcan-ajax-filtered",function(){a("div.yith-wcan-select-wrapper ul.yith-wcan-select li.chosen");t();a("div.yith-wcan-select-wrapper").each(function(){var h="";a(this).find("ul.yith-wcan-select li.chosen").each(function(){h+=a(this).text()+", "});h=h.substring(0,h.length-2);""!=h&&a(this).parent().find("a.yit-wcan-select-open").text(h)})});a(document).on("ready",t);a("body").on("click",function(h){a(h.target).hasClass("yit-wcan-select-open")||
|
16 |
-
t()});if(1==yith_wcan.flatsome.is_enabled&&1==yith_wcan.flatsome.lazy_load_enabled)a(document).on("yith-wcan-ajax-filtered",function(h,p){var b=a(document);jQuery(".lazy-load",b).each(function(a,b){var c=jQuery(b);c.waypoint(function(a){if(!c.hasClass("lazy-load-active")){a=c.data("src");var b=c.data("srcset");a&&c.attr("src",a);b&&c.attr("srcset",b);c.imagesLoaded(function(){c.addClass("lazy-load-active").removeClass("lazy-load")})}},{offset:"140%"})})})});
|
13 |
[e,f])}a(document).trigger("yith-wcan-ajax-reset-filtered")}x()}})};a(yith_wcan.container).not(".ywcps-products").wrap('<div class="yit-wcan-container"></div>');a(document).on("yith-wcan-wrapped",function(){x()});a(document).trigger("yith-wcan-wrapped");a(document).on("click",".yith-wcan a",function(h){a(this).yith_wcan_ajax_filters(h,this)});var t=function(){a("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",opacity:0},0);a("a.yit-wcan-select-open").removeClass("active")};
|
14 |
a(document).on("click","a.yit-wcan-select-open.active",function(h){h.preventDefault();a(this).parent().find("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",opacity:0},300);a(this).parent().find("a.yit-wcan-select-open").removeClass("active")});a(document).on("click","a.yit-wcan-select-open:not(.active)",function(h){h.preventDefault();a("a.yit-wcan-select-open.active").trigger("click");a(this).parent().find("div.yith-wcan-select-wrapper").css("z-index","1").animate({visibility:"visible",
|
15 |
opacity:1},300);a(this).parent().find("a.yit-wcan-select-open").addClass("active")});a(document).on("ready yith-wcan-ajax-filtered",function(){a("div.yith-wcan-select-wrapper ul.yith-wcan-select li.chosen");t();a("div.yith-wcan-select-wrapper").each(function(){var h="";a(this).find("ul.yith-wcan-select li.chosen").each(function(){h+=a(this).text()+", "});h=h.substring(0,h.length-2);""!=h&&a(this).parent().find("a.yit-wcan-select-open").text(h)})});a(document).on("ready",t);a("body").on("click",function(h){a(h.target).hasClass("yit-wcan-select-open")||
|
16 |
+
t()});if(1==yith_wcan.flatsome.is_enabled&&1==yith_wcan.flatsome.lazy_load_enabled)a(document).on("yith-wcan-ajax-filtered",function(h,p){var b=a(document);jQuery(".lazy-load",b).each(function(a,b){var c=jQuery(b);c.waypoint(function(a){if(!c.hasClass("lazy-load-active")){a=c.data("src");var b=c.data("srcset");a&&c.attr("src",a);b&&c.attr("srcset",b);c.imagesLoaded(function(){c.addClass("lazy-load-active").removeClass("lazy-load")})}},{offset:"140%"})})});window.addEventListener("popstate",function(a){window.location.reload(!0)})});
|
includes/class.yith-wcan-frontend.php
CHANGED
@@ -170,7 +170,7 @@ if ( ! class_exists( 'YITH_WCAN_Frontend' ) ) {
|
|
170 |
);
|
171 |
}
|
172 |
|
173 |
-
$this->unfiltered_product_ids = get_posts( $unfiltered_args );
|
174 |
$this->filtered_product_ids = $queried_post_ids;
|
175 |
|
176 |
// Also store filtered posts ids...
|
170 |
);
|
171 |
}
|
172 |
|
173 |
+
$this->unfiltered_product_ids = apply_filters( 'yith_wcan_unfiltered_product_ids', get_posts( $unfiltered_args ), $query, $current_wp_query );
|
174 |
$this->filtered_product_ids = $queried_post_ids;
|
175 |
|
176 |
// Also store filtered posts ids...
|
includes/functions.yith-wcan.php
CHANGED
@@ -217,7 +217,7 @@ if ( ! function_exists( 'yit_reorder_terms_by_parent' ) ) {
|
|
217 |
usort( $child_terms[$term->term_id], 'yit_terms_sort' );
|
218 |
}
|
219 |
|
220 |
-
|
221 |
usort( $child_terms[$term->term_id], 'yit_alphabetical_terms_sort' );
|
222 |
}
|
223 |
|
@@ -233,7 +233,7 @@ if ( ! function_exists( 'yit_reorder_terms_by_parent' ) ) {
|
|
233 |
usort( $terms, 'yit_terms_sort' );
|
234 |
}
|
235 |
|
236 |
-
|
237 |
usort( $terms, 'yit_alphabetical_terms_sort' );
|
238 |
}
|
239 |
|
@@ -402,9 +402,13 @@ if ( ! function_exists( 'yit_get_filter_args' ) ) {
|
|
402 |
*
|
403 |
* @since 1.4
|
404 |
*/
|
405 |
-
function yit_get_filter_args( $
|
|
|
|
|
|
|
|
|
406 |
$filter_value = array();
|
407 |
-
$regexs = array( '/^filter_[a-zA-Z0-9]/', '/^query_type_[a-zA-Z0-9]/', '/product_tag/' );
|
408 |
|
409 |
/* Support to YITH WooCommerce Brands */
|
410 |
if ( yith_wcan_brands_enabled() ) {
|
@@ -425,29 +429,47 @@ if ( ! function_exists( 'yit_get_filter_args' ) ) {
|
|
425 |
if ( $check_price_filter ) {
|
426 |
// WooCommerce Price Filter
|
427 |
if ( isset( $_GET['min_price'] ) ) {
|
428 |
-
$
|
429 |
}
|
430 |
|
431 |
if ( isset( $_GET['max_price'] ) ) {
|
432 |
-
$
|
433 |
}
|
434 |
}
|
435 |
|
436 |
// WooCommerce In Stock/On Sale filters
|
437 |
if ( isset( $_GET['instock_filter'] ) ) {
|
438 |
-
$
|
439 |
}
|
440 |
|
441 |
if ( isset( $_GET['onsale_filter'] ) ) {
|
442 |
-
$
|
443 |
}
|
444 |
|
445 |
if ( isset( $_GET['orderby'] ) ) {
|
446 |
-
$
|
447 |
}
|
448 |
|
449 |
if ( isset( $_GET['product_tag'] ) ) {
|
450 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
}
|
452 |
|
453 |
return $filter_value;
|
@@ -495,9 +517,12 @@ if ( ! function_exists( 'yit_get_woocommerce_layered_nav_link' ) ) {
|
|
495 |
*/
|
496 |
function yit_get_woocommerce_layered_nav_link() {
|
497 |
$return = false;
|
|
|
|
|
|
|
498 |
if ( defined( 'SHOP_IS_ON_FRONT' ) || ( is_shop() && ! is_product_category() ) ) {
|
499 |
-
$taxonomy = get_query_var( 'taxonomy' );
|
500 |
-
$brands_taxonomy = yit_get_brands_taxonomy();
|
501 |
$return = get_post_type_archive_link( 'product' );
|
502 |
|
503 |
// if( ! empty( $brands_taxonomy ) && $brands_taxonomy == $taxonomy ){
|
@@ -506,24 +531,25 @@ if ( ! function_exists( 'yit_get_woocommerce_layered_nav_link' ) ) {
|
|
506 |
return apply_filters( 'yith_wcan_untrailingslashit', true ) && is_string( $return ) ? untrailingslashit( $return ) : $return;
|
507 |
}
|
508 |
|
509 |
-
elseif ( ! is_shop() && is_product_category() ) {
|
510 |
$return = get_term_link( get_queried_object()->slug, 'product_cat' );
|
511 |
return apply_filters( 'yith_wcan_untrailingslashit', true ) && is_string( $return ) ? untrailingslashit( $return ) : $return;
|
512 |
}
|
513 |
|
514 |
else {
|
515 |
-
$
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
$check_for_brands = ! empty( $brands_taxonomy ) && $brands_taxonomy == $taxonomy;
|
521 |
-
|
522 |
-
if( ! $check_for_brands ){
|
523 |
-
$return = get_term_link( yith_wcan_is_product_attribute() && is_numeric( $term ) ? intval( $term ) : $term, $taxonomy );
|
524 |
-
|
525 |
}
|
526 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
527 |
return apply_filters( 'yith_wcan_untrailingslashit', true ) && is_string( $return ) ? untrailingslashit( $return ) : $return;
|
528 |
}
|
529 |
|
@@ -630,12 +656,17 @@ if( ! function_exists( 'yit_reorder_hierachical_categories' ) ) {
|
|
630 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
631 |
*/
|
632 |
function yit_reorder_hierachical_categories( $parent_term_id, $taxonomy = 'product_cat' ) {
|
|
|
|
|
|
|
633 |
$childs = yith_wcan_wp_get_terms(
|
634 |
array(
|
635 |
'taxonomy' => $taxonomy,
|
636 |
'parent' => $parent_term_id,
|
637 |
'hierarchical' => true,
|
638 |
-
'hide_empty' => false
|
|
|
|
|
639 |
)
|
640 |
);
|
641 |
|
217 |
usort( $child_terms[$term->term_id], 'yit_terms_sort' );
|
218 |
}
|
219 |
|
220 |
+
elseif( 'alphabetical' == yith_wcan_get_option( 'yith_wcan_ajax_shop_terms_order', 'alphabetical' ) ) {
|
221 |
usort( $child_terms[$term->term_id], 'yit_alphabetical_terms_sort' );
|
222 |
}
|
223 |
|
233 |
usort( $terms, 'yit_terms_sort' );
|
234 |
}
|
235 |
|
236 |
+
elseif( 'alphabetical' == yith_wcan_get_option( 'yith_wcan_ajax_shop_terms_order', 'alphabetical' ) ){
|
237 |
usort( $terms, 'yit_alphabetical_terms_sort' );
|
238 |
}
|
239 |
|
402 |
*
|
403 |
* @since 1.4
|
404 |
*/
|
405 |
+
function yit_get_filter_args( $args = array() ) {
|
406 |
+
$default_args = array( 'check_price_filter' => true );
|
407 |
+
$args = wp_parse_args( $args, $default_args );
|
408 |
+
extract( $args );
|
409 |
+
|
410 |
$filter_value = array();
|
411 |
+
$regexs = array( '/^filter_[a-zA-Z0-9]/', '/^query_type_[a-zA-Z0-9]/', '/product_tag/', '/product_cat/', '/source_id/', '/source_tax/' );
|
412 |
|
413 |
/* Support to YITH WooCommerce Brands */
|
414 |
if ( yith_wcan_brands_enabled() ) {
|
429 |
if ( $check_price_filter ) {
|
430 |
// WooCommerce Price Filter
|
431 |
if ( isset( $_GET['min_price'] ) ) {
|
432 |
+
$filter_value['min_price'] = $_GET['min_price'];
|
433 |
}
|
434 |
|
435 |
if ( isset( $_GET['max_price'] ) ) {
|
436 |
+
$filter_value['max_price'] = $_GET['max_price'];
|
437 |
}
|
438 |
}
|
439 |
|
440 |
// WooCommerce In Stock/On Sale filters
|
441 |
if ( isset( $_GET['instock_filter'] ) ) {
|
442 |
+
$filter_value['instock_filter'] = $_GET['instock_filter'];
|
443 |
}
|
444 |
|
445 |
if ( isset( $_GET['onsale_filter'] ) ) {
|
446 |
+
$filter_value['onsale_filter'] = $_GET['onsale_filter'];
|
447 |
}
|
448 |
|
449 |
if ( isset( $_GET['orderby'] ) ) {
|
450 |
+
$filter_value['orderby'] = $_GET['orderby'];
|
451 |
}
|
452 |
|
453 |
if ( isset( $_GET['product_tag'] ) ) {
|
454 |
+
$filter_value['product_tag'] = urlencode( $_GET['product_tag'] );
|
455 |
+
}
|
456 |
+
|
457 |
+
if (isset($_GET['product_cat'])) {
|
458 |
+
$filter_value['product_cat'] = urlencode( $_GET['product_cat'] );
|
459 |
+
}
|
460 |
+
|
461 |
+
elseif( is_product_category() && $queried_object ){
|
462 |
+
$filter_value['product_cat'] = $queried_object->slug;
|
463 |
+
}
|
464 |
+
|
465 |
+
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
466 |
+
$filter_value['source_id'] = $_GET['source_id'];
|
467 |
+
$filter_value['source_tax'] = $_GET['source_tax'];
|
468 |
+
}
|
469 |
+
|
470 |
+
elseif( is_product_taxonomy() && $queried_object && ! isset( $filter_value['source_id'] ) && ! isset( $filter_value['source_tax'] )){
|
471 |
+
$filter_value['source_id'] = $queried_object->slug;
|
472 |
+
$filter_value['source_tax'] = $queried_object->taxonomy;
|
473 |
}
|
474 |
|
475 |
return $filter_value;
|
517 |
*/
|
518 |
function yit_get_woocommerce_layered_nav_link() {
|
519 |
$return = false;
|
520 |
+
$term = $source_id = ! empty( $_GET['source_id'] ) ? $_GET['source_id'] : '';
|
521 |
+
$taxonomy = $source_tax = ! empty( $_GET['source_tax'] ) ? $_GET['source_tax'] : '';
|
522 |
+
|
523 |
if ( defined( 'SHOP_IS_ON_FRONT' ) || ( is_shop() && ! is_product_category() ) ) {
|
524 |
+
// $taxonomy = get_query_var( 'taxonomy' );
|
525 |
+
// $brands_taxonomy = yit_get_brands_taxonomy();
|
526 |
$return = get_post_type_archive_link( 'product' );
|
527 |
|
528 |
// if( ! empty( $brands_taxonomy ) && $brands_taxonomy == $taxonomy ){
|
531 |
return apply_filters( 'yith_wcan_untrailingslashit', true ) && is_string( $return ) ? untrailingslashit( $return ) : $return;
|
532 |
}
|
533 |
|
534 |
+
elseif ( ! is_shop() && is_product_category( $source_id ) && false ) {
|
535 |
$return = get_term_link( get_queried_object()->slug, 'product_cat' );
|
536 |
return apply_filters( 'yith_wcan_untrailingslashit', true ) && is_string( $return ) ? untrailingslashit( $return ) : $return;
|
537 |
}
|
538 |
|
539 |
else {
|
540 |
+
if( empty( $taxonomy ) || empty( $term ) ){
|
541 |
+
$queried_object = get_queried_object();
|
542 |
+
$taxonomy = $queried_object instanceof WP_Term ? $queried_object->taxonomy : get_query_var( 'taxonomy' );
|
543 |
+
$term = $queried_object instanceof WP_Term ? $queried_object : get_query_var( 'term' );
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
}
|
545 |
|
546 |
+
// if( yith_wcan_is_product_attribute() || is_numeric( $term ) ){
|
547 |
+
// $term = intval( $term );
|
548 |
+
// }
|
549 |
+
//
|
550 |
+
// $return = get_term_link( $term, $taxonomy );
|
551 |
+
$return = get_post_type_archive_link( 'product' );
|
552 |
+
|
553 |
return apply_filters( 'yith_wcan_untrailingslashit', true ) && is_string( $return ) ? untrailingslashit( $return ) : $return;
|
554 |
}
|
555 |
|
656 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
657 |
*/
|
658 |
function yit_reorder_hierachical_categories( $parent_term_id, $taxonomy = 'product_cat' ) {
|
659 |
+
$exclude = apply_filters( 'yith_wcan_exclude_terms', array() );
|
660 |
+
$include = apply_filters( 'yith_wcan_include_terms', array() );
|
661 |
+
|
662 |
$childs = yith_wcan_wp_get_terms(
|
663 |
array(
|
664 |
'taxonomy' => $taxonomy,
|
665 |
'parent' => $parent_term_id,
|
666 |
'hierarchical' => true,
|
667 |
+
'hide_empty' => false,
|
668 |
+
'include' => $include,
|
669 |
+
'exclude' => $exclude
|
670 |
)
|
671 |
);
|
672 |
|
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.
|
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.
|
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.2.0
|
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.2.0' );
|
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 |
|
plugin-fw/lib/yit-plugin-panel.php
CHANGED
@@ -324,7 +324,7 @@ if ( ! class_exists( 'YIT_Plugin_Panel' ) ) {
|
|
324 |
}
|
325 |
?>
|
326 |
<div id="icon-themes" class="icon32"><br /></div>
|
327 |
-
<h2 class="nav-tab-wrapper">
|
328 |
<?php echo $tabs ?>
|
329 |
</h2>
|
330 |
<?php
|
324 |
}
|
325 |
?>
|
326 |
<div id="icon-themes" class="icon32"><br /></div>
|
327 |
+
<h2 class="yith nav-tab-wrapper">
|
328 |
<?php echo $tabs ?>
|
329 |
</h2>
|
330 |
<?php
|
plugin-fw/licence/lib/yit-licence.php
CHANGED
@@ -95,8 +95,9 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
|
|
95 |
}
|
96 |
|
97 |
/* Update Licence Information */
|
98 |
-
|
99 |
-
add_action( '
|
|
|
100 |
|
101 |
}
|
102 |
|
95 |
}
|
96 |
|
97 |
/* Update Licence Information */
|
98 |
+
//@TODO: Removed for performance
|
99 |
+
// add_action( 'core_upgrade_preamble', array( $this, 'check_all' ) );
|
100 |
+
// add_action( 'wp_maybe_auto_update', array( $this, 'check_all' ) );
|
101 |
|
102 |
}
|
103 |
|
plugin-fw/yit-plugin.php
CHANGED
@@ -19,6 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
19 |
! defined( 'YIT_CORE_PLUGIN_TEMPLATE_PATH' ) && define( 'YIT_CORE_PLUGIN_TEMPLATE_PATH', YIT_CORE_PLUGIN_PATH . '/templates' );
|
20 |
|
21 |
include_once( 'yit-functions.php' );
|
|
|
22 |
include_once( 'yit-plugin-registration-hook.php' );
|
23 |
include_once( 'lib/yit-metabox.php' );
|
24 |
include_once( 'lib/yit-plugin-panel.php' );
|
19 |
! defined( 'YIT_CORE_PLUGIN_TEMPLATE_PATH' ) && define( 'YIT_CORE_PLUGIN_TEMPLATE_PATH', YIT_CORE_PLUGIN_PATH . '/templates' );
|
20 |
|
21 |
include_once( 'yit-functions.php' );
|
22 |
+
include_once( 'yit-woocommerce-compatibility.php' );
|
23 |
include_once( 'yit-plugin-registration-hook.php' );
|
24 |
include_once( 'lib/yit-metabox.php' );
|
25 |
include_once( 'lib/yit-plugin-panel.php' );
|
plugin-fw/yit-woocommerce-compatibility.php
ADDED
@@ -0,0 +1,408 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file belongs to the YIT Plugin Framework.
|
4 |
+
*
|
5 |
+
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
|
6 |
+
* that is bundled with this package in the file LICENSE.txt.
|
7 |
+
* It is also available through the world-wide-web at this URL:
|
8 |
+
* http://www.gnu.org/licenses/gpl-3.0.txt
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
} // Exit if accessed directly
|
14 |
+
|
15 |
+
$changed_objects = array();
|
16 |
+
|
17 |
+
if ( ! function_exists( 'yit_get_prop' ) ) {
|
18 |
+
/**
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
function yit_get_prop( $object, $key, $single = true ) {
|
22 |
+
|
23 |
+
$prop_map = yit_return_new_attribute_map();
|
24 |
+
$is_wc_data = $object instanceof WC_Data;
|
25 |
+
|
26 |
+
if ( $is_wc_data ) {
|
27 |
+
$key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
|
28 |
+
|
29 |
+
if ( ( $getter = "get{$key}" ) && method_exists( $object, $getter ) ) {
|
30 |
+
return $object->$getter();
|
31 |
+
}
|
32 |
+
elseif ( ( $getter = "get_{$key}" ) && method_exists( $object, $getter ) ) {
|
33 |
+
return $object->$getter();
|
34 |
+
}
|
35 |
+
else {
|
36 |
+
return $object->get_meta( $key, $single );
|
37 |
+
}
|
38 |
+
} else {
|
39 |
+
$key = ( in_array( $key, $prop_map ) ) ? array_search( $key, $prop_map ) : $key;
|
40 |
+
|
41 |
+
if ( isset( $object->$key ) ) {
|
42 |
+
return $object->$key;
|
43 |
+
}
|
44 |
+
elseif ( yit_wc_check_post_columns( $key ) ) {
|
45 |
+
return $object->post->$key;
|
46 |
+
}
|
47 |
+
else {
|
48 |
+
$getter = 'get_user_meta';
|
49 |
+
! $object instanceof WC_Customer && $getter = 'get_post_meta';
|
50 |
+
|
51 |
+
return $getter( $object->id, $key, true );
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
if ( ! function_exists( 'yit_set_prop' ) ) {
|
58 |
+
/**
|
59 |
+
*
|
60 |
+
*/
|
61 |
+
function yit_set_prop( $object, $arg1, $arg2 = false ) {
|
62 |
+
|
63 |
+
if( ! is_array( $arg1 ) ){
|
64 |
+
$arg1 = array(
|
65 |
+
$arg1 => $arg2
|
66 |
+
);
|
67 |
+
}
|
68 |
+
|
69 |
+
$prop_map = yit_return_new_attribute_map();
|
70 |
+
$is_wc_data = $object instanceof WC_Data;
|
71 |
+
|
72 |
+
foreach( $arg1 as $key => $value ) {
|
73 |
+
if ( $is_wc_data ) {
|
74 |
+
$key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
|
75 |
+
|
76 |
+
if ( ( $setter = "set{$key}" ) && method_exists( $object, $setter ) ) {
|
77 |
+
$object->$setter( $value );
|
78 |
+
}
|
79 |
+
elseif ( ( $setter = "set_{$key}" ) && method_exists( $object, $setter ) ) {
|
80 |
+
$object->$setter( $value );
|
81 |
+
}
|
82 |
+
else {
|
83 |
+
$object->update_meta_data( $key, $value );
|
84 |
+
}
|
85 |
+
}
|
86 |
+
else {
|
87 |
+
$key = ( in_array( $key, $prop_map ) ) ? array_search( $key, $prop_map ) : $key;
|
88 |
+
( strpos( $key, '_' ) === 0 ) && $key = substr( $key, 1 );
|
89 |
+
|
90 |
+
if ( yit_wc_check_post_columns( $key ) ) {
|
91 |
+
$object->post->$key = $value;
|
92 |
+
}
|
93 |
+
else {
|
94 |
+
$object->$key = $value;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
if ( ! function_exists( 'yit_save_prop' ) ) {
|
102 |
+
/**
|
103 |
+
*
|
104 |
+
*/
|
105 |
+
function yit_save_prop( $object, $arg1, $arg2 = false, $force_meta = false ) {
|
106 |
+
if( ! is_array( $arg1 ) ){
|
107 |
+
$arg1 = array(
|
108 |
+
$arg1 => $arg2
|
109 |
+
);
|
110 |
+
}
|
111 |
+
|
112 |
+
$is_wc_data = $object instanceof WC_Data;
|
113 |
+
|
114 |
+
foreach( $arg1 as $key => $value ) {
|
115 |
+
yit_set_prop( $object, $key, $value );
|
116 |
+
|
117 |
+
if ( $is_wc_data ) {
|
118 |
+
yit_store_changes( $object, $key, $value );
|
119 |
+
}
|
120 |
+
else {
|
121 |
+
if ( yit_wc_check_post_columns( $key ) ) {
|
122 |
+
yit_store_changes( $object->post, $key, $value );
|
123 |
+
}
|
124 |
+
else {
|
125 |
+
update_post_meta( $object->id, $key, $value );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
if ( ! function_exists( 'yit_delete_prop' ) ) {
|
133 |
+
/**
|
134 |
+
*
|
135 |
+
*/
|
136 |
+
function yit_delete_prop( $object, $key, $value = '' ) {
|
137 |
+
$prop_map = yit_return_new_attribute_map();
|
138 |
+
$is_wc_data = $object instanceof WC_Data;
|
139 |
+
|
140 |
+
if ( $is_wc_data ) {
|
141 |
+
$key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
|
142 |
+
|
143 |
+
if ( ( $setter = "set{$key}" ) && ( $getter = "get{$key}" ) && method_exists( $object, $setter ) && ( ! $value || $object->$getter == $value ) ) {
|
144 |
+
$object->$setter( '' );
|
145 |
+
}
|
146 |
+
elseif ( ( $setter = "set_{$key}" ) && ( $getter = "get_{$key}" ) && method_exists( $object, $setter ) && ( ! $value || $object->$getter == $value ) ) {
|
147 |
+
$object->$setter( '' );
|
148 |
+
}
|
149 |
+
elseif( ( ! $value || $object->get_meta( $key ) == $value ) ) {
|
150 |
+
$object->delete_meta_data( $key, $value );
|
151 |
+
}
|
152 |
+
|
153 |
+
yit_store_changes( $object );
|
154 |
+
} else {
|
155 |
+
if ( yit_wc_check_post_columns( $key ) && ( ! $value || $object->post->$key == $value ) ) {
|
156 |
+
yit_store_changes( $object->post, $key, '' );
|
157 |
+
}
|
158 |
+
else {
|
159 |
+
delete_post_meta( $object->id, $key, $value );
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
if( ! function_exists( 'yit_return_new_attribute_map' ) ){
|
166 |
+
function yit_return_new_attribute_map(){
|
167 |
+
return array(
|
168 |
+
'post_parent' => 'parent_id',
|
169 |
+
'post_title' => 'name',
|
170 |
+
'post_status' => 'status',
|
171 |
+
'post_content' => 'description',
|
172 |
+
'paid_date' => 'date_paid',
|
173 |
+
'_paid_date' => '_date_paid',
|
174 |
+
'completed_date' => 'date_completed',
|
175 |
+
'_completed_date' => '_date_completed'
|
176 |
+
);
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
if( ! function_exists( 'yit_store_changes' ) ){
|
181 |
+
function yit_store_changes( $object, $key = false, $value = false ){
|
182 |
+
global $changed_objects;
|
183 |
+
|
184 |
+
$is_wc_data = $object instanceof WC_Data;
|
185 |
+
|
186 |
+
if( $is_wc_data ){
|
187 |
+
/**
|
188 |
+
* @var $object \WC_Data
|
189 |
+
*/
|
190 |
+
$class_name = get_class( $object );
|
191 |
+
$object_reference = $object->get_id();
|
192 |
+
|
193 |
+
$changed_objects[ $object_reference ][ 'object' ] = $object;
|
194 |
+
$changed_objects[ $object_reference ][ 'changes' ] = array_merge(
|
195 |
+
isset( $changed_objects[ $object_reference ][ 'changes' ] ) ? $changed_objects[ $object_reference ][ 'changes' ] : array(),
|
196 |
+
array( $key => $value )
|
197 |
+
);
|
198 |
+
}
|
199 |
+
else {
|
200 |
+
$changed_objects[ $object->ID ][ $key ] = $value;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
if( ! function_exists( 'yit_send_changes_to_db' ) ){
|
206 |
+
function yit_send_changes_to_db(){
|
207 |
+
global $changed_objects;
|
208 |
+
|
209 |
+
if( ! empty( $changed_objects ) ){
|
210 |
+
foreach ( $changed_objects as $id => $data ) {
|
211 |
+
if( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
212 |
+
/**
|
213 |
+
* @var $object \WC_Data
|
214 |
+
*/
|
215 |
+
$object = $data['object'];
|
216 |
+
|
217 |
+
yit_set_prop( $object, $data['changes'] );
|
218 |
+
|
219 |
+
$object->save();
|
220 |
+
}
|
221 |
+
else{
|
222 |
+
$data['ID'] = $id;
|
223 |
+
wp_update_post( $data );
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
if( ! function_exists( 'yit_get_orders' ) ){
|
231 |
+
/**
|
232 |
+
*
|
233 |
+
*/
|
234 |
+
function yit_get_orders( $args ){
|
235 |
+
if( version_compare( WC()->version, '2.6', '<' ) ){
|
236 |
+
$args['fields'] = 'objects';
|
237 |
+
$posts = get_posts( $args );
|
238 |
+
|
239 |
+
return array_map( 'wc_get_order', $posts );
|
240 |
+
}
|
241 |
+
else{
|
242 |
+
return wc_get_orders( $args );
|
243 |
+
}
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
if( ! function_exists( 'yit_get_products' ) ){
|
248 |
+
/**
|
249 |
+
*
|
250 |
+
*/
|
251 |
+
function yit_get_products( $args ){
|
252 |
+
if( version_compare( WC()->version, '2.6', '<' ) ){
|
253 |
+
$args['fields'] = 'objects';
|
254 |
+
$posts = get_posts( $args );
|
255 |
+
|
256 |
+
return array_map( 'wc_get_product', $posts );
|
257 |
+
}
|
258 |
+
else{
|
259 |
+
return wc_get_products( $args );
|
260 |
+
}
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
if( ! function_exists( 'yit_update_product_stock' ) ){
|
265 |
+
/**
|
266 |
+
*
|
267 |
+
*/
|
268 |
+
function yit_update_product_stock( $product, $stock_quantity = 1, $operation = 'set' ){
|
269 |
+
if( function_exists( 'wc_update_product_stock' ) ){
|
270 |
+
$stock = wc_update_product_stock( $product, $stock_quantity, $operation );
|
271 |
+
}
|
272 |
+
else{
|
273 |
+
switch( $operation ){
|
274 |
+
case 'increase':
|
275 |
+
$stock = $product->increase_stock( $stock_quantity );
|
276 |
+
break;
|
277 |
+
case 'decrease':
|
278 |
+
$stock = $product->reduce_stock( $stock_quantity );
|
279 |
+
break;
|
280 |
+
case 'set':
|
281 |
+
default:
|
282 |
+
$stock = $product->set_stock( $stock_quantity );
|
283 |
+
break;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
return $stock;
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
if ( ! function_exists( 'yit_wc_deprecated_filters' ) ) {
|
292 |
+
/**
|
293 |
+
*
|
294 |
+
*/
|
295 |
+
function yit_wc_deprecated_filters() {
|
296 |
+
return apply_filters( 'yit_wc_deprecated_filters', array(
|
297 |
+
'woocommerce_email_order_schema_markup' => 'woocommerce_structured_data_order',
|
298 |
+
'woocommerce_product_width' => 'woocommerce_product_get_width',
|
299 |
+
'woocommerce_product_height' => 'woocommerce_product_get_height',
|
300 |
+
'woocommerce_product_length' => 'woocommerce_product_get_length',
|
301 |
+
'woocommerce_product_weight' => 'woocommerce_product_get_weight',
|
302 |
+
'woocommerce_get_sku' => 'woocommerce_product_get_sku',
|
303 |
+
'woocommerce_get_price' => 'woocommerce_product_get_price',
|
304 |
+
'woocommerce_get_regular_price' => 'woocommerce_product_get_regular_price',
|
305 |
+
'woocommerce_get_sale_price' => 'woocommerce_product_get_sale_price',
|
306 |
+
'woocommerce_product_tax_class' => 'woocommerce_product_get_tax_class',
|
307 |
+
'woocommerce_get_stock_quantity' => 'woocommerce_product_get_stock_quantity',
|
308 |
+
'woocommerce_get_product_attributes' => 'woocommerce_product_get_attributes',
|
309 |
+
'woocommerce_product_gallery_attachment_ids' => 'woocommerce_product_get_gallery_image_ids',
|
310 |
+
'woocommerce_product_review_count' => 'woocommerce_product_get_review_count',
|
311 |
+
'woocommerce_product_files' => 'woocommerce_product_get_downloads',
|
312 |
+
'woocommerce_get_currency' => 'woocommerce_order_get_currency',
|
313 |
+
'woocommerce_order_amount_discount_total' => 'woocommerce_order_get_discount_total',
|
314 |
+
'woocommerce_order_amount_discount_tax' => 'woocommerce_order_get_discount_tax',
|
315 |
+
'woocommerce_order_amount_shipping_total' => 'woocommerce_order_get_shipping_total',
|
316 |
+
'woocommerce_order_amount_shipping_tax' => 'woocommerce_order_get_shipping_tax',
|
317 |
+
'woocommerce_order_amount_cart_tax' => 'woocommerce_order_get_cart_tax',
|
318 |
+
'woocommerce_order_amount_total' => 'woocommerce_order_get_total',
|
319 |
+
'woocommerce_order_amount_total_tax' => 'woocommerce_order_get_total_tax',
|
320 |
+
'woocommerce_order_amount_total_discount' => 'woocommerce_order_get_total_discount',
|
321 |
+
'woocommerce_order_amount_subtotal' => 'woocommerce_order_get_subtotal',
|
322 |
+
'woocommerce_order_tax_totals' => 'woocommerce_order_get_tax_totals',
|
323 |
+
'woocommerce_refund_amount' => 'woocommerce_get_order_refund_get_amount',
|
324 |
+
'woocommerce_refund_reason' => 'woocommerce_get_order_refund_get_reason',
|
325 |
+
'default_checkout_country' => 'default_checkout_billing_country',
|
326 |
+
'default_checkout_state' => 'default_checkout_billing_state',
|
327 |
+
'default_checkout_postcode' => 'default_checkout_billing_postcode',
|
328 |
+
'woocommerce_add_order_item_meta' => 'woocommerce_new_order_item',
|
329 |
+
'woocommerce_product_write_panels' => 'woocommerce_product_data_panels'
|
330 |
+
) );
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
if( ! function_exists( 'yit_fix_wc_deprecated_filters' ) ){
|
335 |
+
/**
|
336 |
+
*
|
337 |
+
*/
|
338 |
+
function yit_fix_wc_deprecated_filters(){
|
339 |
+
|
340 |
+
if( ! version_compare( WC()->version, '2.7.0', '<' ) ) {
|
341 |
+
return;
|
342 |
+
}
|
343 |
+
|
344 |
+
$deprecated_filters = yit_wc_deprecated_filters();
|
345 |
+
foreach ( $deprecated_filters as $old => $new ) {
|
346 |
+
add_filter( $old, 'yit_wc_deprecated_filter_mapping', 10, 100 );
|
347 |
+
}
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
if( ! function_exists( 'yit_wc_deprecated_filter_mapping' ) ) {
|
352 |
+
/**
|
353 |
+
*
|
354 |
+
*/
|
355 |
+
function yit_wc_deprecated_filter_mapping() {
|
356 |
+
$deprecated_filters = yit_wc_deprecated_filters();
|
357 |
+
|
358 |
+
$filter = current_filter();
|
359 |
+
$args = func_get_args();
|
360 |
+
$data = $args[0];
|
361 |
+
|
362 |
+
|
363 |
+
if ( isset( $deprecated_filters[ $filter ] ) ) {
|
364 |
+
if ( has_filter( $deprecated_filters[ $filter ] ) ) {
|
365 |
+
$data = apply_filters_ref_array( $deprecated_filters[ $filter ], $args );
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
return $data;
|
370 |
+
}
|
371 |
+
}
|
372 |
+
|
373 |
+
if( ! function_exists( 'yit_wc_check_post_columns' ) ) {
|
374 |
+
/**
|
375 |
+
*
|
376 |
+
*/
|
377 |
+
function yit_wc_check_post_columns( $key ) {
|
378 |
+
$columns = array(
|
379 |
+
'post_author',
|
380 |
+
'post_date',
|
381 |
+
'post_date_gmt',
|
382 |
+
'post_content',
|
383 |
+
'post_title',
|
384 |
+
'post_excerpt',
|
385 |
+
'post_status',
|
386 |
+
'comment_status',
|
387 |
+
'ping_status',
|
388 |
+
'post_password',
|
389 |
+
'post_name',
|
390 |
+
'to_ping',
|
391 |
+
'pinged',
|
392 |
+
'post_modified',
|
393 |
+
'post_modified_gmt',
|
394 |
+
'post_content_filtered',
|
395 |
+
'post_parent',
|
396 |
+
'guid',
|
397 |
+
'menu_order',
|
398 |
+
'post_type',
|
399 |
+
'post_mime_type',
|
400 |
+
'comment_count',
|
401 |
+
);
|
402 |
+
|
403 |
+
return in_array( $key, $columns );
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
yit_fix_wc_deprecated_filters();
|
408 |
+
add_action( 'shutdown', 'yit_send_changes_to_db' );
|
screenshot-1.png
DELETED
Binary file
|
screenshot-10.png
DELETED
Binary file
|
screenshot-2.png
DELETED
Binary file
|
screenshot-3.png
DELETED
Binary file
|
screenshot-4.png
DELETED
Binary file
|
screenshot-5.png
DELETED
Binary file
|
screenshot-6.png
DELETED
Binary file
|
screenshot-7.png
DELETED
Binary file
|
screenshot-8.png
DELETED
Binary file
|
screenshot-9.png
DELETED
Binary file
|
widgets/class.yith-wcan-navigation-widget.php
CHANGED
@@ -42,6 +42,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
42 |
|
43 |
function widget( $args, $instance ) {
|
44 |
$_chosen_attributes = YITH_WCAN()->get_layered_nav_chosen_attributes();
|
|
|
45 |
|
46 |
extract( $args );
|
47 |
$_attributes_array = yit_wcan_get_product_taxonomy();
|
@@ -111,7 +112,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
111 |
|
112 |
if ( in_array( $display_type, apply_filters( 'yith_wcan_display_type_list', array( 'list' ) ) ) ) {
|
113 |
|
114 |
-
|
115 |
array(
|
116 |
'taxonomy' => $taxonomy,
|
117 |
'parent' => 0,
|
@@ -126,7 +127,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
126 |
usort( $ancestors, 'yit_terms_sort' );
|
127 |
}
|
128 |
|
129 |
-
|
130 |
usort( $ancestors, 'yit_alphabetical_terms_sort' );
|
131 |
}
|
132 |
|
@@ -161,7 +162,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
161 |
foreach ( $terms as $term ) {
|
162 |
|
163 |
// Get count based on current view - uses transients
|
164 |
-
|
165 |
|
166 |
//if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
|
167 |
|
@@ -178,11 +179,11 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
178 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
|
179 |
|
180 |
// skip the term for the current archive
|
181 |
-
if ( $current_term == $term->$filter_term_field ) {
|
182 |
-
continue;
|
183 |
-
}
|
184 |
|
185 |
-
if ( $count > 0
|
186 |
$this->found = true;
|
187 |
}
|
188 |
|
@@ -195,9 +196,9 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
195 |
else {
|
196 |
|
197 |
// skip the term for the current archive
|
198 |
-
if ( $current_term == $term->$filter_term_field ) {
|
199 |
-
continue;
|
200 |
-
}
|
201 |
|
202 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->unfiltered_product_ids ) );
|
203 |
|
@@ -262,12 +263,16 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
262 |
}
|
263 |
|
264 |
if ( isset( $_GET[ $this->brand_taxonomy ] ) ) {
|
265 |
-
$brands = get_term_by( '
|
266 |
if( $brands instanceof WP_Term && $brands->term_id != $term->term_id ){
|
267 |
$link = add_query_arg( $this->brand_taxonomy, urlencode( $brands->slug ), $link );
|
268 |
}
|
269 |
}
|
270 |
|
|
|
|
|
|
|
|
|
271 |
if( isset( $_GET['product_cat'] ) ){
|
272 |
$categories_filter_operator = 'and' == $query_type ? '+' : ',';
|
273 |
$_chosen_categories = explode( $categories_filter_operator, urlencode( $_GET['product_cat'] ) );
|
@@ -278,6 +283,29 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
278 |
);
|
279 |
}
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
// Current Filter = this widget
|
282 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
283 |
|
@@ -352,13 +380,12 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
352 |
if ( $query_type == 'and' ) {
|
353 |
|
354 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
|
355 |
-
|
356 |
// skip the term for the current archive
|
357 |
-
if ( $current_term == $term->$filter_term_field ) {
|
358 |
-
continue;
|
359 |
-
}
|
360 |
|
361 |
-
if ( $count > 0
|
362 |
$this->found = true;
|
363 |
}
|
364 |
|
@@ -371,9 +398,9 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
371 |
else {
|
372 |
|
373 |
// skip the term for the current archive
|
374 |
-
if ( $current_term == $term->$filter_term_field ) {
|
375 |
-
continue;
|
376 |
-
}
|
377 |
|
378 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->unfiltered_product_ids ) );
|
379 |
|
@@ -438,12 +465,16 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
438 |
}
|
439 |
|
440 |
if ( isset( $_GET[ $this->brand_taxonomy ] ) ) {
|
441 |
-
$brands = get_term_by( '
|
442 |
if( $brands instanceof WP_Term && $brands->term_id != $term->term_id ){
|
443 |
$link = add_query_arg( $this->brand_taxonomy, urlencode( $brands->slug ), $link );
|
444 |
}
|
445 |
}
|
446 |
|
|
|
|
|
|
|
|
|
447 |
if( isset( $_GET['product_cat'] ) ){
|
448 |
$categories_filter_operator = 'and' == $query_type ? '+' : ',';
|
449 |
$_chosen_categories = explode( $categories_filter_operator, urlencode( $_GET['product_cat'] ) );
|
@@ -454,6 +485,29 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
454 |
);
|
455 |
}
|
456 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
// Current Filter = this widget
|
458 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
459 |
|
@@ -511,7 +565,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
511 |
foreach ( $terms as $term ) {
|
512 |
|
513 |
// Get count based on current view - uses transients
|
514 |
-
$transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
|
515 |
|
516 |
//if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
|
517 |
|
@@ -528,11 +582,11 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
528 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
|
529 |
|
530 |
// skip the term for the current archive
|
531 |
-
if ( $current_term == $term->$filter_term_field ) {
|
532 |
-
continue;
|
533 |
-
}
|
534 |
|
535 |
-
if ( $count > 0
|
536 |
$this->found = true;
|
537 |
}
|
538 |
|
@@ -545,9 +599,9 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
545 |
else {
|
546 |
|
547 |
// skip the term for the current archive
|
548 |
-
if ( $current_term == $term->$filter_term_field ) {
|
549 |
-
continue;
|
550 |
-
}
|
551 |
|
552 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->unfiltered_product_ids ) );
|
553 |
|
@@ -612,12 +666,16 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
612 |
}
|
613 |
|
614 |
if ( isset( $_GET[ $this->brand_taxonomy ] ) ) {
|
615 |
-
$brands = get_term_by( '
|
616 |
if( $brands instanceof WP_Term && $brands->term_id != $term->term_id ){
|
617 |
$link = add_query_arg( $this->brand_taxonomy, urlencode( $brands->slug ), $link );
|
618 |
}
|
619 |
}
|
620 |
|
|
|
|
|
|
|
|
|
621 |
if( isset( $_GET['product_cat'] ) ){
|
622 |
$categories_filter_operator = 'and' == $query_type ? '+' : ',';
|
623 |
$_chosen_categories = explode( $categories_filter_operator, urlencode( $_GET['product_cat'] ) );
|
@@ -628,6 +686,29 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
628 |
);
|
629 |
}
|
630 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
631 |
// Current Filter = this widget
|
632 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
633 |
|
@@ -871,6 +952,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
871 |
$_chosen_attributes = YITH_WCAN()->get_layered_nav_chosen_attributes();
|
872 |
$in_array_function = apply_filters( 'yith_wcan_in_array_ignor_case', false ) ? 'yit_in_array_ignore_case' : 'in_array';
|
873 |
$terms = apply_filters( 'yith_wcan_get_list_html_terms', $terms, $taxonomy, $instance );
|
|
|
874 |
foreach ( $terms as $parent_id => $term_ids ) {
|
875 |
$term = get_term_by( 'id', $parent_id, $taxonomy );
|
876 |
|
@@ -984,8 +1066,24 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
984 |
if ( $brands instanceof WP_Term && $brands->term_id != $term->term_id ) {
|
985 |
$link = add_query_arg($this->brand_taxonomy, urlencode($brands->slug), $link);
|
986 |
}
|
|
|
|
|
|
|
|
|
|
|
987 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
988 |
|
|
|
|
|
|
|
989 |
}
|
990 |
|
991 |
if (isset($_GET['product_cat'])) {
|
@@ -998,6 +1096,15 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
998 |
);
|
999 |
}
|
1000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1001 |
$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']);
|
1002 |
$class = '';
|
1003 |
|
@@ -1076,9 +1183,11 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
|
|
1076 |
$li_printed = true;
|
1077 |
}
|
1078 |
|
1079 |
-
$show_count = $count != 0 &&
|
|
|
|
|
1080 |
|
1081 |
-
if ( $to_print && apply_filters( 'yith_wcan_force_show_count',
|
1082 |
echo ' <small class="count">' . $count . '</small><div class="clear"></div>';
|
1083 |
}
|
1084 |
|
42 |
|
43 |
function widget( $args, $instance ) {
|
44 |
$_chosen_attributes = YITH_WCAN()->get_layered_nav_chosen_attributes();
|
45 |
+
$queried_object = get_queried_object();
|
46 |
|
47 |
extract( $args );
|
48 |
$_attributes_array = yit_wcan_get_product_taxonomy();
|
112 |
|
113 |
if ( in_array( $display_type, apply_filters( 'yith_wcan_display_type_list', array( 'list' ) ) ) ) {
|
114 |
|
115 |
+
$ancestors = yith_wcan_wp_get_terms(
|
116 |
array(
|
117 |
'taxonomy' => $taxonomy,
|
118 |
'parent' => 0,
|
127 |
usort( $ancestors, 'yit_terms_sort' );
|
128 |
}
|
129 |
|
130 |
+
elseif( 'alphabetical' == yith_wcan_get_option( 'yith_wcan_ajax_shop_terms_order', 'alphabetical' ) ){
|
131 |
usort( $ancestors, 'yit_alphabetical_terms_sort' );
|
132 |
}
|
133 |
|
162 |
foreach ( $terms as $term ) {
|
163 |
|
164 |
// Get count based on current view - uses transients
|
165 |
+
//$transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
|
166 |
|
167 |
//if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
|
168 |
|
179 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
|
180 |
|
181 |
// skip the term for the current archive
|
182 |
+
// if ( $current_term == $term->$filter_term_field ) {
|
183 |
+
// continue;
|
184 |
+
// }
|
185 |
|
186 |
+
if ( $count > 0 ) {
|
187 |
$this->found = true;
|
188 |
}
|
189 |
|
196 |
else {
|
197 |
|
198 |
// skip the term for the current archive
|
199 |
+
// if ( $current_term == $term->$filter_term_field ) {
|
200 |
+
// continue;
|
201 |
+
// }
|
202 |
|
203 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->unfiltered_product_ids ) );
|
204 |
|
263 |
}
|
264 |
|
265 |
if ( isset( $_GET[ $this->brand_taxonomy ] ) ) {
|
266 |
+
$brands = get_term_by( 'slug', $_GET[ $this->brand_taxonomy ], $this->brand_taxonomy );
|
267 |
if( $brands instanceof WP_Term && $brands->term_id != $term->term_id ){
|
268 |
$link = add_query_arg( $this->brand_taxonomy, urlencode( $brands->slug ), $link );
|
269 |
}
|
270 |
}
|
271 |
|
272 |
+
elseif( is_tax( $this->brand_taxonomy ) && $queried_object ) {
|
273 |
+
$link = add_query_arg( array( $this->brand_taxonomy => $queried_object->slug ), $link );
|
274 |
+
}
|
275 |
+
|
276 |
if( isset( $_GET['product_cat'] ) ){
|
277 |
$categories_filter_operator = 'and' == $query_type ? '+' : ',';
|
278 |
$_chosen_categories = explode( $categories_filter_operator, urlencode( $_GET['product_cat'] ) );
|
283 |
);
|
284 |
}
|
285 |
|
286 |
+
elseif( is_product_category() && $queried_object ){
|
287 |
+
//Removed @JoseCostaRos
|
288 |
+
$link = add_query_arg( array( 'product_cat' => $queried_object->slug ), $link );
|
289 |
+
}
|
290 |
+
|
291 |
+
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
292 |
+
$link = add_query_arg( array( 'source_id' => $queried_object->term_id, 'source_tax' => $queried_object->taxonomy ), $link );
|
293 |
+
}
|
294 |
+
|
295 |
+
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
296 |
+
$add_source_id = true;
|
297 |
+
if( $term->term_id == $queried_object->term_id ){
|
298 |
+
$parse = parse_url( $link );
|
299 |
+
if( empty( $parse['query'] ) ){
|
300 |
+
$add_source_id = false;
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
if( $add_source_id ) {
|
305 |
+
$link = add_query_arg( array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] ), $link );
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
// Current Filter = this widget
|
310 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
311 |
|
380 |
if ( $query_type == 'and' ) {
|
381 |
|
382 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
|
|
|
383 |
// skip the term for the current archive
|
384 |
+
// if ( $current_term == $term->$filter_term_field ) {
|
385 |
+
// continue;
|
386 |
+
// }
|
387 |
|
388 |
+
if ( $count > 0 ) {
|
389 |
$this->found = true;
|
390 |
}
|
391 |
|
398 |
else {
|
399 |
|
400 |
// skip the term for the current archive
|
401 |
+
// if ( $current_term == $term->$filter_term_field ) {
|
402 |
+
// continue;
|
403 |
+
// }
|
404 |
|
405 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->unfiltered_product_ids ) );
|
406 |
|
465 |
}
|
466 |
|
467 |
if ( isset( $_GET[ $this->brand_taxonomy ] ) ) {
|
468 |
+
$brands = get_term_by( 'slug', $_GET[ $this->brand_taxonomy ], $this->brand_taxonomy );
|
469 |
if( $brands instanceof WP_Term && $brands->term_id != $term->term_id ){
|
470 |
$link = add_query_arg( $this->brand_taxonomy, urlencode( $brands->slug ), $link );
|
471 |
}
|
472 |
}
|
473 |
|
474 |
+
elseif( is_tax( $this->brand_taxonomy ) && $queried_object ) {
|
475 |
+
$link = add_query_arg( array( $this->brand_taxonomy => $queried_object->slug ), $link );
|
476 |
+
}
|
477 |
+
|
478 |
if( isset( $_GET['product_cat'] ) ){
|
479 |
$categories_filter_operator = 'and' == $query_type ? '+' : ',';
|
480 |
$_chosen_categories = explode( $categories_filter_operator, urlencode( $_GET['product_cat'] ) );
|
485 |
);
|
486 |
}
|
487 |
|
488 |
+
elseif( is_product_category() && $queried_object ){
|
489 |
+
//Removed @JoseCostaRos
|
490 |
+
$link = add_query_arg( array( 'product_cat' => $queried_object->slug ), $link );
|
491 |
+
}
|
492 |
+
|
493 |
+
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
494 |
+
$link = add_query_arg( array( 'source_id' => $queried_object->term_id, 'source_tax' => $queried_object->taxonomy ), $link );
|
495 |
+
}
|
496 |
+
|
497 |
+
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
498 |
+
$add_source_id = true;
|
499 |
+
if( $term->term_id == $queried_object->term_id ){
|
500 |
+
$parse = parse_url( $link );
|
501 |
+
if( empty( $parse['query'] ) ){
|
502 |
+
$add_source_id = false;
|
503 |
+
}
|
504 |
+
}
|
505 |
+
|
506 |
+
if( $add_source_id ) {
|
507 |
+
$link = add_query_arg( array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] ), $link );
|
508 |
+
}
|
509 |
+
}
|
510 |
+
|
511 |
// Current Filter = this widget
|
512 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
513 |
|
565 |
foreach ( $terms as $term ) {
|
566 |
|
567 |
// Get count based on current view - uses transients
|
568 |
+
// $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
|
569 |
|
570 |
//if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
|
571 |
|
582 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->layered_nav_product_ids ) );
|
583 |
|
584 |
// skip the term for the current archive
|
585 |
+
// if ( $current_term == $term->$filter_term_field ) {
|
586 |
+
// continue;
|
587 |
+
// }
|
588 |
|
589 |
+
if ( $count > 0 ) {
|
590 |
$this->found = true;
|
591 |
}
|
592 |
|
599 |
else {
|
600 |
|
601 |
// skip the term for the current archive
|
602 |
+
// if ( $current_term == $term->$filter_term_field ) {
|
603 |
+
// continue;
|
604 |
+
// }
|
605 |
|
606 |
$count = sizeof( array_intersect( $_products_in_term, YITH_WCAN()->frontend->unfiltered_product_ids ) );
|
607 |
|
666 |
}
|
667 |
|
668 |
if ( isset( $_GET[ $this->brand_taxonomy ] ) ) {
|
669 |
+
$brands = get_term_by( 'slug', $_GET[ $this->brand_taxonomy ], $this->brand_taxonomy );
|
670 |
if( $brands instanceof WP_Term && $brands->term_id != $term->term_id ){
|
671 |
$link = add_query_arg( $this->brand_taxonomy, urlencode( $brands->slug ), $link );
|
672 |
}
|
673 |
}
|
674 |
|
675 |
+
elseif( is_tax( $this->brand_taxonomy ) && $queried_object ) {
|
676 |
+
$link = add_query_arg( array( $this->brand_taxonomy => $queried_object->slug ), $link );
|
677 |
+
}
|
678 |
+
|
679 |
if( isset( $_GET['product_cat'] ) ){
|
680 |
$categories_filter_operator = 'and' == $query_type ? '+' : ',';
|
681 |
$_chosen_categories = explode( $categories_filter_operator, urlencode( $_GET['product_cat'] ) );
|
686 |
);
|
687 |
}
|
688 |
|
689 |
+
elseif( is_product_category() && $queried_object ){
|
690 |
+
//Removed @JoseCostaRos
|
691 |
+
$link = add_query_arg( array( 'product_cat' => $queried_object->slug ), $link );
|
692 |
+
}
|
693 |
+
|
694 |
+
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
695 |
+
$link = add_query_arg( array( 'source_id' => $queried_object->term_id, 'source_tax' => $queried_object->taxonomy ), $link );
|
696 |
+
}
|
697 |
+
|
698 |
+
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
699 |
+
$add_source_id = true;
|
700 |
+
if( $term->term_id == $queried_object->term_id ){
|
701 |
+
$parse = parse_url( $link );
|
702 |
+
if( empty( $parse['query'] ) ){
|
703 |
+
$add_source_id = false;
|
704 |
+
}
|
705 |
+
}
|
706 |
+
|
707 |
+
if( $add_source_id ) {
|
708 |
+
$link = add_query_arg( array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] ), $link );
|
709 |
+
}
|
710 |
+
}
|
711 |
+
|
712 |
// Current Filter = this widget
|
713 |
if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && $in_array_function( $term->$filter_term_field, $_chosen_attributes[$taxonomy]['terms'] ) ) {
|
714 |
|
952 |
$_chosen_attributes = YITH_WCAN()->get_layered_nav_chosen_attributes();
|
953 |
$in_array_function = apply_filters( 'yith_wcan_in_array_ignor_case', false ) ? 'yit_in_array_ignore_case' : 'in_array';
|
954 |
$terms = apply_filters( 'yith_wcan_get_list_html_terms', $terms, $taxonomy, $instance );
|
955 |
+
$queried_object = get_queried_object();
|
956 |
foreach ( $terms as $parent_id => $term_ids ) {
|
957 |
$term = get_term_by( 'id', $parent_id, $taxonomy );
|
958 |
|
1066 |
if ( $brands instanceof WP_Term && $brands->term_id != $term->term_id ) {
|
1067 |
$link = add_query_arg($this->brand_taxonomy, urlencode($brands->slug), $link);
|
1068 |
}
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
elseif( is_tax( $this->brand_taxonomy ) && $queried_object ) {
|
1072 |
+
$link = add_query_arg( array( $this->brand_taxonomy => $queried_object->slug ), $link );
|
1073 |
+
}
|
1074 |
|
1075 |
+
if ( isset( $_GET['source_id'] ) && isset( $_GET['source_tax'] ) ) {
|
1076 |
+
$add_source_id = true;
|
1077 |
+
if( $term->term_id == $queried_object->term_id ){
|
1078 |
+
$parse = parse_url( $link );
|
1079 |
+
if( empty( $parse['query'] ) ){
|
1080 |
+
$add_source_id = false;
|
1081 |
+
}
|
1082 |
+
}
|
1083 |
|
1084 |
+
if( $add_source_id ) {
|
1085 |
+
$link = add_query_arg( array( 'source_id' => $_GET['source_id'], 'source_tax' => $_GET['source_tax'] ), $link );
|
1086 |
+
}
|
1087 |
}
|
1088 |
|
1089 |
if (isset($_GET['product_cat'])) {
|
1096 |
);
|
1097 |
}
|
1098 |
|
1099 |
+
elseif( is_product_category() && $queried_object ){
|
1100 |
+
//Removed @JoseCostaRos
|
1101 |
+
$link = add_query_arg( array( 'product_cat' => $queried_object->slug ), $link );
|
1102 |
+
}
|
1103 |
+
|
1104 |
+
if( is_product_taxonomy() && ! yit_is_filtered_uri() && $term->term_id != $queried_object->term_id ){
|
1105 |
+
$link = add_query_arg( array( 'source_id' => $queried_object->term_id, 'source_tax' => $queried_object->taxonomy ), $link );
|
1106 |
+
}
|
1107 |
+
|
1108 |
$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']);
|
1109 |
$class = '';
|
1110 |
|
1183 |
$li_printed = true;
|
1184 |
}
|
1185 |
|
1186 |
+
$show_count = $count != 0 && ! empty( $instance['show_count'] ) && ! $instance['show_count'];
|
1187 |
+
|
1188 |
+
$show_count = apply_filters( "{$args['widget_id']}-show_product_count", $show_count, $instance );
|
1189 |
|
1190 |
+
if ( $to_print && apply_filters( 'yith_wcan_force_show_count', $show_count ) ) {
|
1191 |
echo ' <small class="count">' . $count . '</small><div class="clear"></div>';
|
1192 |
}
|
1193 |
|
widgets/class.yith-wcan-reset-navigation-widget.php
CHANGED
@@ -66,7 +66,7 @@ if ( ! class_exists( 'YITH_WCAN_Reset_Navigation_Widget' ) ) {
|
|
66 |
|
67 |
else{
|
68 |
//Start filter from Product category Page
|
69 |
-
$term = get_term_by( 'id', $_GET['source_id'], '
|
70 |
$link = get_term_link( $term, $term->taxonomy );
|
71 |
}
|
72 |
|
66 |
|
67 |
else{
|
68 |
//Start filter from Product category Page
|
69 |
+
$term = get_term_by( 'id', $_GET['source_id'], $_GET['source_tax'] );
|
70 |
$link = get_term_link( $term, $term->taxonomy );
|
71 |
}
|
72 |
|