'Display Products Category Widget', 'classname' => 'articles-products-category-widget' ) ); } // print to frontend function widget( $args, $instance ) { // Widget output extract($args); echo $before_widget; $tpl = PBR_THEME_DIR .'/templates/widgets/products_category.php'; require( $tpl ); echo $after_widget; } function update( $new_instance, $old_instance ) { // Save widget options $instance['title'] = $new_instance['title']; $instance['type'] = $new_instance['type']; $instance['category'] = $new_instance['category']; $instance['number'] = $new_instance['number']; $instance['number_sub'] = $new_instance['number_sub']; $instance['columns'] = $new_instance['columns']; $instance['addition_class'] = $new_instance['addition_class']; return $instance; } function form( $instance ) { //default $instance = wp_parse_args( $instance, array( 'title' => 'Products Category', 'type' => 'featured_product', 'category' => '', 'number' => '4', 'number_sub' => '4', 'columns' => '4', 'addition_class' => '', ) ); $types = [ 'best_selling' => __('Best Selling', 'basee'), 'featured_product' => __('Featured', 'basee'), 'top_rate' => __('Top Rate', 'basee'), 'recent_product' => __('Recent Product', 'basee'), 'on_sale' => __('On Sale', 'basee'), 'recent_review' => __('Recent Review', 'basee'), ]; $columns = [ '1' => __('1', 'basee'), '2' => __('2', 'basee'), '3' => __('3', 'basee'), '4' => __('4', 'basee'), '6' => __('6', 'basee'), ]; $product_categories_dropdown = array(); $args = array( 'type' => 'post', 'child_of' => 0, 'parent' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'product_cat', 'pad_counts' => false, ); $categories = get_categories( $args ); $this->pbr_getcategorychilds( 0, $categories, 0, $product_categories_dropdown ); ?>
$value) { if ( $value->category_parent == $parent_id ) { $data = array( $value->slug => str_repeat( "- ", $level ) . $value->name . '('. $value->term_id .')', ); $dropdown = array_merge( $dropdown, $data ); unset($array[$key]); $this->pbr_getcategorychilds( $value->term_id, $array, $level + 1, $dropdown ); } } } }