diff --git a/includes/widgets/class-wc-widget-product-categories.php b/includes/widgets/class-wc-widget-product-categories.php index cdec8c7b506..3d75219889d 100644 --- a/includes/widgets/class-wc-widget-product-categories.php +++ b/includes/widgets/class-wc-widget-product-categories.php @@ -1,17 +1,21 @@ settings['dropdown']['std']; $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : $this->settings['orderby']['std']; $hide_empty = isset( $instance['hide_empty'] ) ? $instance['hide_empty'] : $this->settings['hide_empty']['std']; - $dropdown_args = array( 'hide_empty' => $hide_empty ); - $list_args = array( 'show_count' => $count, 'hierarchical' => $hierarchical, 'taxonomy' => 'product_cat', 'hide_empty' => $hide_empty ); - $max_depth = absint( isset( $instance['max_depth'] ) ? $instance['max_depth'] : $this->settings['max_depth']['std']); + $dropdown_args = array( + 'hide_empty' => $hide_empty, + ); + $list_args = array( + 'show_count' => $count, + 'hierarchical' => $hierarchical, + 'taxonomy' => 'product_cat', + 'hide_empty' => $hide_empty, + ); + $max_depth = absint( isset( $instance['max_depth'] ) ? $instance['max_depth'] : $this->settings['max_depth']['std'] ); $list_args['menu_order'] = false; $dropdown_args['depth'] = $max_depth; @@ -125,7 +136,9 @@ class WC_Widget_Product_Categories extends WC_Widget { $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); } elseif ( is_singular( 'product' ) ) { - $product_category = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array( 'orderby' => 'parent' ) ) ); + $product_category = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array( + 'orderby' => 'parent', + ) ) ); if ( ! empty( $product_category ) ) { $this->current_cat = end( $product_category ); @@ -183,9 +196,10 @@ class WC_Widget_Product_Categories extends WC_Widget { 'hide_empty' => false, ) ); - } + } // End if(). - $dropdown_args['include'] = $list_args['include'] = implode( ',', $include ); + $list_args['include'] = implode( ',', $include ); + $dropdown_args['include'] = $list_args['include']; if ( empty( $include ) ) { return; @@ -197,7 +211,7 @@ class WC_Widget_Product_Categories extends WC_Widget { $list_args['depth'] = 1; $list_args['child_of'] = 0; $list_args['hierarchical'] = 1; - } + } // End if(). $this->widget_start( $args, $instance ); @@ -230,7 +244,7 @@ class WC_Widget_Product_Categories extends WC_Widget { $list_args['title_li'] = ''; $list_args['pad_counts'] = 1; $list_args['show_option_none'] = __( 'No product categories exist.', 'woocommerce' ); - $list_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id: ''; + $list_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : ''; $list_args['current_category_ancestors'] = $this->cat_ancestors; echo ''; - } + } // End if(). $this->widget_end( $args ); }