widget_cssclass = 'woocommerce product_category_meta_widget'; $this->widget_description = __( 'Display product Category with a product count', 'best-shop' ); $this->widget_id = 'best_shop_product_cat_meta_widget'; $this->widget_name = __( '+ Product Category List', 'best-shop' ); parent::__construct(); } public function widget($args, $instance) { $max_items = (!empty($instance['max_items'])) ? strip_tags($instance['max_items']) : 6; $min_height = (!empty($instance['min_height'])) ? strip_tags($instance['min_height']) : 200; $category = (!empty($instance['category'])) ? strip_tags($instance['category']) : ''; $colums = (!empty($instance['colums'])) ? strip_tags($instance['colums']) : "col-md-12 col-sm-12 col-lg-12 col-xs-12"; $cat_count = 0; global $best_shop_product_categories; best_shop_set_all_product_categories(); $all_categories = $best_shop_product_categories; echo '
'; } public function form($instance) { $max_items = (!empty($instance['max_items'])) ? strip_tags($instance['max_items']) : 6; $min_height = (!empty($instance['min_height'])) ? strip_tags($instance['min_height']) : 200; $category = (!empty($instance['category'])) ? strip_tags($instance['category']) : ''; $colums = (!empty($instance['colums'])) ? strip_tags($instance['colums']) : "col-md-12 col-sm-12 col-lg-12 col-xs-12"; $product_colums = array( "col-md-12 col-sm-12 col-lg-12 col-xs-12" => 1, "col-md-6 col-sm-6 col-lg-6 col-xs-12" => 2, "col-md-4 col-sm-4 col-lg-4 col-xs-12" => 3, "col-md-3 col-sm-3 col-lg-3 col-xs-12" => 4, "col-md-2 col-sm-2 col-lg-2 col-xs-12" => 6, ); $args = array( 'taxonomy' => 'product_cat', 'orderby' => 'date', 'order' => 'ASC', 'show_count' => 1, 'pad_counts' => 0, 'hierarchical' => 0, 'title_li' => '', 'hide_empty' => 1, ); $categories = get_categories($args); $category_list = ''; if (0 == $category) { $category_list = $category_list . ''; } else { $category_list = $category_list . ''; } foreach ($categories as $cat) { $selected = ''; if (($cat->term_id) == $category) { $selected = 'Selected=selected'; } $category_list = $category_list . ''; } ?>