diff --git a/includes/widgets/class-wc-widget-layered-nav-filters.php b/includes/widgets/class-wc-widget-layered-nav-filters.php index e7b7a5c96cf..20fa43f6990 100644 --- a/includes/widgets/class-wc-widget-layered-nav-filters.php +++ b/includes/widgets/class-wc-widget-layered-nav-filters.php @@ -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 diff --git a/includes/widgets/class-wc-widget-layered-nav.php b/includes/widgets/class-wc-widget-layered-nav.php index 56155795571..3efe79470d4 100644 --- a/includes/widgets/class-wc-widget-layered-nav.php +++ b/includes/widgets/class-wc-widget-layered-nav.php @@ -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' ) { diff --git a/woocommerce-functions.php b/woocommerce-functions.php index dcadb97e5c3..cbd0d15ec86 100644 --- a/woocommerce-functions.php +++ b/woocommerce-functions.php @@ -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;