Enable for all taxonomies

This commit is contained in:
Mike Jolley 2013-06-20 11:21:31 +01:00
parent be7d7005d3
commit 1ff10d6ccf
3 changed files with 12 additions and 18 deletions

View File

@ -41,15 +41,15 @@ class WC_Widget_Layered_Nav_Filters extends WC_Widget {
* @return void
*/
public function widget( $args, $instance ) {
global $_chosen_attributes, $woocommerce, $_attributes_array;
global $_chosen_attributes, $woocommerce;
extract( $args );
if ( ! is_post_type_archive( 'product' ) && is_array( $_attributes_array ) && ! is_tax( array_merge( $_attributes_array, array( 'product_cat', 'product_tag' ) ) ) )
if ( ! is_post_type_archive( 'product' ) && ! is_tax( get_object_taxonomies( 'product' ) ) )
return;
$current_term = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->term_id : '';
$current_tax = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->taxonomy : '';
$current_term = is_tax() ? get_queried_object()->term_id : '';
$current_tax = is_tax() ? get_queried_object()->taxonomy : '';
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
// Price

View File

@ -75,16 +75,15 @@ class WC_Widget_Layered_Nav extends WC_Widget {
* @return void
*/
public function widget( $args, $instance ) {
global $_chosen_attributes, $woocommerce, $_attributes_array;
global $_chosen_attributes, $woocommerce;
extract( $args );
if ( ! is_post_type_archive( 'product' ) && ! is_tax( array_merge( $_attributes_array, array( 'product_cat', 'product_tag' ) ) ) )
if ( ! is_post_type_archive( 'product' ) && ! is_tax( get_object_taxonomies( 'product' ) ) )
return;
$current_term = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->term_id : '';
$current_tax = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->taxonomy : '';
$current_term = is_tax() ? get_queried_object()->term_id : '';
$current_tax = is_tax() ? get_queried_object()->taxonomy : '';
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
$taxonomy = $woocommerce->get_helper( 'attribute' )->attribute_taxonomy_name($instance['attribute']);
$query_type = isset( $instance['query_type'] ) ? $instance['query_type'] : 'and';
@ -104,9 +103,8 @@ class WC_Widget_Layered_Nav extends WC_Widget {
echo $before_widget . $before_title . $title . $after_title;
// Force found when option is selected - do not force found on taxonomy attributes
if ( ! $_attributes_array || ! is_tax( $_attributes_array ) )
if ( is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) )
$found = true;
if ( ! is_tax() && is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) )
$found = true;
if ( $display_type == 'dropdown' ) {

View File

@ -1364,9 +1364,9 @@ function woocommerce_layered_nav_init( ) {
if ( is_active_widget( false, false, 'woocommerce_layered_nav', true ) && ! is_admin() ) {
global $_chosen_attributes, $woocommerce, $_attributes_array;
global $_chosen_attributes, $woocommerce;
$_chosen_attributes = $_attributes_array = array();
$_chosen_attributes = array();
$attribute_taxonomies = $woocommerce->get_helper( 'attribute' )->get_attribute_taxonomies();
if ( $attribute_taxonomies ) {
@ -1374,10 +1374,6 @@ function woocommerce_layered_nav_init( ) {
$attribute = sanitize_title( $tax->attribute_name );
$taxonomy = $woocommerce->get_helper( 'attribute' )->attribute_taxonomy_name( $attribute );
// create an array of product attribute taxonomies
$_attributes_array[] = $taxonomy;
$name = 'filter_' . $attribute;
$query_type_name = 'query_type_' . $attribute;