esc_html__('A widget that shows WooCommerce multiple category', '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 ); $title_style = array( 'layout_one' => esc_html__('Layout One', 'sparklestore'), 'layout_two' => esc_html__('Layout Two', 'sparklestore') ); $display_layout = array( 'category-style-1' => esc_html__('Display Style One', 'sparklestore'), 'category-style-2' => esc_html__('Display Style Two', 'sparklestore') ); $woocommerce_categories = array(); $woocommerce_categories_obj = get_categories( $args ); foreach( $woocommerce_categories_obj as $category ) { $woocommerce_categories[$category->term_id] = $category->name; } $fields = array( 'block_title_layout' => array( 'sparklestore_widgets_name' => 'block_title_layout', 'sparklestore_widgets_title' => esc_html__( 'Select Block Title Style', 'sparklestore' ), 'sparklestore_widgets_default' => 'layout_one', 'sparklestore_widgets_field_type' => 'select', 'sparklestore_widgets_field_options' => $title_style ), 'sparklestore_main_cat_title' => array( 'sparklestore_widgets_name' => 'sparklestore_main_cat_title', 'sparklestore_widgets_title' => esc_html__('Main Title', 'sparklestore'), 'sparklestore_widgets_field_type' => 'title', ), 'sparklestore_cat_short_desc' => array( 'sparklestore_widgets_name' => 'sparklestore_cat_short_desc', 'sparklestore_widgets_title' => esc_html__('Short Description', 'sparklestore'), 'sparklestore_widgets_field_type' => 'textarea', 'sparklestore_widgets_row' => 4, ), 'block_display_style_layout' => array( 'sparklestore_widgets_name' => 'block_display_style_layout', 'sparklestore_widgets_title' => esc_html__( 'Select Display Style', 'sparklestore' ), 'sparklestore_widgets_default' => 'category-style-1', 'sparklestore_widgets_field_type' => 'select', 'sparklestore_widgets_field_options' => $display_layout ), 'sparklestore_select_category' => array( 'sparklestore_widgets_name' => 'sparklestore_select_category', 'sparklestore_mulicheckbox_title' => esc_html__('Select Category', 'sparklestore'), 'sparklestore_widgets_field_type' => 'multicheckboxes', 'sparklestore_widgets_field_options' => $woocommerce_categories ), 'block_display_layout' => array( 'sparklestore_widgets_name' => 'block_display_layout', 'sparklestore_widgets_title' => esc_html__( 'Display Block Layouts', 'sparklestore' ), 'sparklestore_widgets_default' => 'layout1', 'sparklestore_widgets_field_type' => 'selector', 'sparklestore_widgets_field_options' => array( 'layout1' => esc_url( get_template_directory_uri() . '/assets/images/layout1.png' ), 'layout2' => esc_url( get_template_directory_uri() . '/assets/images/layout2.png' ) ) ), ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** * wp query for first block */ $title_layout = empty( $instance['block_title_layout'] ) ? 'layout_one' : $instance['block_title_layout']; $main_title = empty( $instance['sparklestore_main_cat_title'] ) ? '' : $instance['sparklestore_main_cat_title']; $shot_desc = empty( $instance['sparklestore_cat_short_desc'] ) ? '' : $instance['sparklestore_cat_short_desc']; $sparklestore_cat_id = empty( $instance['sparklestore_select_category'] ) ? '' : $instance['sparklestore_select_category']; $block_layout = empty( $instance['block_display_layout'] ) ? 'layout1' : $instance['block_display_layout']; $display_style = empty( $instance['block_display_style_layout'] ) ? 'category-style-1' : $instance['block_display_style_layout']; echo $before_widget; ?>