woo_widget_cssclass = 'widget_product_categories'; $this->woo_widget_description = __( 'A list or dropdown of product categories.', 'woocommerce' ); $this->woo_widget_idbase = 'woocommerce_product_categories'; $this->woo_widget_name = __('WooCommerce Product Categories', 'woocommerce' ); /* Widget settings. */ $widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description ); /* Create the widget. */ $this->WP_Widget('product_categories', $this->woo_widget_name, $widget_ops); } /** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Product Categories', 'woocommerce' ) : $instance['title'], $instance, $this->id_base); $c = $instance['count'] ? '1' : '0'; $h = $instance['hierarchical'] ? true : false; $s = (isset($instance['show_children_only']) && $instance['show_children_only']) ? '1' : '0'; $d = $instance['dropdown'] ? '1' : '0'; $o = isset($instance['orderby']) ? $instance['orderby'] : 'order'; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; $cat_args = array('show_count' => $c, 'hierarchical' => $h, 'taxonomy' => 'product_cat'); if ( $o == 'order' ) { $cat_args['menu_order'] = 'asc'; } else { $cat_args['orderby'] = 'title'; } if ( $d ) { // Stuck with this until a fix for http://core.trac.wordpress.org/ticket/13258 woocommerce_product_dropdown_categories( $c, $h, 0 ); ?> current_cat = false; $this->cat_ancestors = array(); if ( is_tax('product_cat') ) : $this->current_cat = $wp_query->queried_object; $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); elseif ( is_singular('product') ) : $product_category = wp_get_post_terms( $post->ID, 'product_cat' ); if ($product_category) : $this->current_cat = end($product_category); $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); endif; endif; include_once( $woocommerce->plugin_path() . '/classes/walkers/class-product-cat-list-walker.php' ); $cat_args['walker'] = new WC_Product_Cat_List_Walker; $cat_args['title_li'] = ''; $cat_args['show_children_only'] = ( isset( $instance['show_children_only'] ) && $instance['show_children_only'] ) ? 1 : 0; $cat_args['pad_counts'] = 1; $cat_args['show_option_none'] = __('No product categories exist.', 'woocommerce'); $cat_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : ''; $cat_args['current_category_ancestors'] = $this->cat_ancestors; echo '
/>
/>
/>
/>