'agency_ecommerce_widget_newsletter', 'description' => esc_html__('Newsletter Widget', 'agency-ecommerce'), ); parent::__construct('agency-ecommerce-newsletter', esc_html__(' Newsletter', 'agency-ecommerce'), $opts); } function widget_fields() { $fields = array( 'title' => array( 'name' => 'title', 'title' => esc_html__('Widget Title', 'agency-ecommerce'), 'type' => 'text', ), 'sub_title' => array( 'name' => 'sub_title', 'title' => esc_html__('Sub Title', 'agency-ecommerce'), 'type' => 'text', ), 'shortcode' => array( 'name' => 'shortcode', 'title' => esc_html__('Shortcode', 'agency-ecommerce'), 'type' => 'text', ), 'background_color' => array( 'name' => 'background_color', 'title' => esc_html__('Background Color', 'agency-ecommerce'), 'type' => 'color', 'default' => '#0b1f41', ) ); return $fields; } /** * Echo the widget content. * * @since 1.0.0 * * @param array $args Display arguments including before_title, after_title, * before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ 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); $sub_title = esc_html($valid_widget_instance['sub_title']); $shortcode = esc_html($valid_widget_instance['shortcode']); $background_color = sanitize_hex_color($valid_widget_instance['background_color']); $args['before_widget'] = str_replace('class="', 'style="background:' . $background_color . ' " class="', $args['before_widget']); echo $args['before_widget']; ?>