Enable for all taxonomies
This commit is contained in:
parent
be7d7005d3
commit
1ff10d6ccf
|
@ -41,15 +41,15 @@ class WC_Widget_Layered_Nav_Filters extends WC_Widget {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function widget( $args, $instance ) {
|
public function widget( $args, $instance ) {
|
||||||
global $_chosen_attributes, $woocommerce, $_attributes_array;
|
global $_chosen_attributes, $woocommerce;
|
||||||
|
|
||||||
extract( $args );
|
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;
|
return;
|
||||||
|
|
||||||
$current_term = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->term_id : '';
|
$current_term = is_tax() ? get_queried_object()->term_id : '';
|
||||||
$current_tax = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->taxonomy : '';
|
$current_tax = is_tax() ? get_queried_object()->taxonomy : '';
|
||||||
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
|
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
|
||||||
|
|
||||||
// Price
|
// Price
|
||||||
|
|
|
@ -75,16 +75,15 @@ class WC_Widget_Layered_Nav extends WC_Widget {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function widget( $args, $instance ) {
|
public function widget( $args, $instance ) {
|
||||||
global $_chosen_attributes, $woocommerce, $_attributes_array;
|
global $_chosen_attributes, $woocommerce;
|
||||||
|
|
||||||
extract( $args );
|
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;
|
return;
|
||||||
|
|
||||||
$current_term = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->term_id : '';
|
$current_term = is_tax() ? get_queried_object()->term_id : '';
|
||||||
$current_tax = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->taxonomy : '';
|
$current_tax = is_tax() ? get_queried_object()->taxonomy : '';
|
||||||
|
|
||||||
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
|
||||||
$taxonomy = $woocommerce->get_helper( 'attribute' )->attribute_taxonomy_name($instance['attribute']);
|
$taxonomy = $woocommerce->get_helper( 'attribute' )->attribute_taxonomy_name($instance['attribute']);
|
||||||
$query_type = isset( $instance['query_type'] ) ? $instance['query_type'] : 'and';
|
$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;
|
echo $before_widget . $before_title . $title . $after_title;
|
||||||
|
|
||||||
// Force found when option is selected - do not force found on taxonomy attributes
|
// Force found when option is selected - do not force found on taxonomy attributes
|
||||||
if ( ! $_attributes_array || ! is_tax( $_attributes_array ) )
|
if ( ! is_tax() && is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) )
|
||||||
if ( is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) )
|
$found = true;
|
||||||
$found = true;
|
|
||||||
|
|
||||||
if ( $display_type == 'dropdown' ) {
|
if ( $display_type == 'dropdown' ) {
|
||||||
|
|
||||||
|
|
|
@ -1364,9 +1364,9 @@ function woocommerce_layered_nav_init( ) {
|
||||||
|
|
||||||
if ( is_active_widget( false, false, 'woocommerce_layered_nav', true ) && ! is_admin() ) {
|
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();
|
$attribute_taxonomies = $woocommerce->get_helper( 'attribute' )->get_attribute_taxonomies();
|
||||||
if ( $attribute_taxonomies ) {
|
if ( $attribute_taxonomies ) {
|
||||||
|
@ -1374,10 +1374,6 @@ function woocommerce_layered_nav_init( ) {
|
||||||
|
|
||||||
$attribute = sanitize_title( $tax->attribute_name );
|
$attribute = sanitize_title( $tax->attribute_name );
|
||||||
$taxonomy = $woocommerce->get_helper( 'attribute' )->attribute_taxonomy_name( $attribute );
|
$taxonomy = $woocommerce->get_helper( 'attribute' )->attribute_taxonomy_name( $attribute );
|
||||||
|
|
||||||
// create an array of product attribute taxonomies
|
|
||||||
$_attributes_array[] = $taxonomy;
|
|
||||||
|
|
||||||
$name = 'filter_' . $attribute;
|
$name = 'filter_' . $attribute;
|
||||||
$query_type_name = 'query_type_' . $attribute;
|
$query_type_name = 'query_type_' . $attribute;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue