esc_html__('A widget that shows WooCommerce category in multiple tabs with category related products', 'sparklestore') )); } private function widget_fields() { $taxonomy = 'product_cat'; $empty = 1; $orderby = 'name'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 1; // 1 for yes, 0 for no $title = ''; $empty = 0; $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title, 'hide_empty' => $empty ); $woocommerce_categories = array(); $woocommerce_categories_obj = get_categories($args); foreach ($woocommerce_categories_obj as $category) { $woocommerce_categories[$category->term_id] = $category->name; } $fields = array( 'sparklestore_select_category' => array( 'sparklestore_widgets_name' => 'sparklestore_select_category', 'sparklestore_mulicheckbox_title' => esc_html__('Select Category Tabs', 'sparklestore'), 'sparklestore_widgets_field_type' => 'multicheckboxes', 'sparklestore_widgets_field_options' => $woocommerce_categories ), 'sparklestore_pro_number_products' => array( 'sparklestore_widgets_name' => 'sparklestore_pro_number_products', 'sparklestore_widgets_title' => esc_html__('Enter the Number Products Display', 'sparklestore'), 'sparklestore_widgets_field_type' => 'number', ) ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** * wp query for first block */ $sparklestore_cat_id = $instance['sparklestore_select_category']; if(!empty( $sparklestore_cat_id )) { $first_cat_id = key( $sparklestore_cat_id ); } $product_number = empty( $instance['sparklestore_pro_number_products'] ) ? 5 : $instance['sparklestore_pro_number_products']; echo $before_widget; ?>