From f49bd2cd771d6de3a349a2c882b40c65b56f8eba Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 8 May 2013 12:16:40 +0100 Subject: [PATCH] Allow layered nav to work with non pa_ prepended taxonomies --- classes/widgets/class-wc-widget-layered-nav.php | 9 ++++++--- readme.txt | 1 + woocommerce-hooks.php | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/classes/widgets/class-wc-widget-layered-nav.php b/classes/widgets/class-wc-widget-layered-nav.php index 1e3c0012041..2b429055e57 100644 --- a/classes/widgets/class-wc-widget-layered-nav.php +++ b/classes/widgets/class-wc-widget-layered-nav.php @@ -229,17 +229,20 @@ class WC_Widget_Layered_Nav extends WP_Widget { foreach ( $_chosen_attributes as $name => $data ) { if ( $name !== $taxonomy ) { - //exclude query arg for current term archive term + // Exclude query arg for current term archive term while ( in_array( $current_term, $data['terms'] ) ) { $key = array_search( $current_term, $data ); unset( $data['terms'][$key] ); } + // Remove pa_ and sanitize + $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) ); + if ( ! empty( $data['terms'] ) ) - $link = add_query_arg( sanitize_title( str_replace( 'pa_', 'filter_', $name ) ), implode(',', $data['terms']), $link ); + $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link ); if ( $data['query_type'] == 'or' ) - $link = add_query_arg( sanitize_title( str_replace( 'pa_', 'query_type_', $name ) ), 'or', $link ); + $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link ); } } } diff --git a/readme.txt b/readme.txt index 9b4d049ec69..4a940f14a98 100644 --- a/readme.txt +++ b/readme.txt @@ -174,6 +174,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Fix - Javascript escapes to stop breaking scripts when used with translations * Fix - PayPal button should use classes 'button' and 'alt', not 'button-alt' * Fix - Have the remove_taxes() method set subtotal to subtotal_ex_tax +* Fix - Allow layered nav to work with non pa_ prepended taxonomies * Refactor - Taken out Piwik integration, use http://wordpress.org/extend/plugins/woocommerce-piwik-integration/ from now on * Refactor - Taken out ShareYourCart integration, use http://wordpress.org/extend/plugins/shareyourcart/ from now on * Refactor - Moved woocommerce_get_formatted_product_name function into WC_Product class diff --git a/woocommerce-hooks.php b/woocommerce-hooks.php index 9244b2dffc4..3ce16bb9a67 100644 --- a/woocommerce-hooks.php +++ b/woocommerce-hooks.php @@ -75,6 +75,7 @@ if ( ! is_admin() || defined('DOING_AJAX') ) { * @see woocommerce_template_loop_add_to_cart() * @see woocommerce_template_loop_product_thumbnail() * @see woocommerce_template_loop_price() + * @see woocommerce_template_loop_rating() */ add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );