'agency_ecommerce_woo_products_widget', 'description' => esc_html__('Widget to display WooCommerce products with advance options.', 'agency-ecommerce'), ); parent::__construct('agency-ecommerce-advanced-products', esc_html__('AE - WOO Products', 'agency-ecommerce'), $opts); } function widget_fields() { $product_type_choices = array( 'latest' => esc_html__('Latest', 'agency-ecommerce'), 'featured' => esc_html__('Featured', 'agency-ecommerce'), ); $fields = array( 'title' => array( 'name' => 'title', 'title' => esc_html__('Title', 'agency-ecommerce'), 'type' => 'text', 'default' => esc_html__('Products', 'agency-ecommerce'), ), 'product_category' => array( 'name' => 'product_category', 'title' => esc_html__('Product Category', 'agency-ecommerce'), 'type' => 'dropdown_categories', 'args' => array( 'taxonomy' => 'product_cat', 'hide_empty' => true, 'orderby' => 'name', 'multiple' => true ), 'default' => array(0) ), 'product_type' => array( 'name' => 'product_type', 'title' => esc_html__('Product Type', 'agency-ecommerce'), 'type' => 'select', 'options' => $product_type_choices, 'default' => 'latest' ), 'number_of_products' => array( 'name' => 'number_of_products', 'title' => esc_html__('Number of products ', 'agency-ecommerce'), 'type' => 'number', 'default' => 6, ), 'disable_carousel' => array( 'name' => 'disable_carousel', 'title' => esc_html__('Disable Carousel', 'agency-ecommerce'), 'type' => 'checkbox', ), 'background_color' => array( 'name' => 'background_color', 'title' => esc_html__('Background Color', 'agency-ecommerce'), 'type' => 'color', 'default' => '#ffffff' ), 'show_category_tab' => array( 'name' => 'show_category_tab', 'title' => esc_html__('Show category tab', 'agency-ecommerce'), 'type' => 'checkbox', 'description' => esc_html__('This option will work only if you disable carousel for this widget.', 'agency-ecommerce'), ) ); return $fields; } function widget($args, $instance) { $valid_widget_instance = Agency_Ecommerce_Widget_Validation::instance()->validate($instance, $this->widget_fields()); $title = apply_filters('widget_title', empty($valid_widget_instance['title']) ? '' : $valid_widget_instance['title'], $valid_widget_instance, $this->id_base); $disable_carousel = $valid_widget_instance['disable_carousel']; $background_color = sanitize_hex_color($valid_widget_instance['background_color']); $show_category_tab = (boolean)($valid_widget_instance['show_category_tab']); $args['before_widget'] = str_replace('class="', 'style="background:' . $background_color . ' " class="', $args['before_widget']); echo $args['before_widget']; ?>