<?php
if ( ! class_exists( 'Draly_Dropshipping_Starter_Elementor_Newsletter' ) ) {
	class Draly_Dropshipping_Starter_Elementor_Newsletter extends Draly_Dropshipping_Starter_Elementor {
		public $name = 'newsletter';
		public $title = 'Newsletter';
		public $icon = 'eicon-mail';

		/**
		 * Register the widget controls.
		 *
		 * Adds different input fields to allow the user to change and customize the widget settings.
		 *
		 * @since 1.0.0
		 *
		 * @access protected
		 */
		protected function register_controls() {

			$this->start_controls_section(
				'general_section',
				[
					'label' => esc_html__( 'General', 'draly-dropshipping-starter' ),
				]
			);
			$this->add_control(
				'style',
				[
					'label'       => esc_html__( 'Style', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => array(
						'style-01' => esc_html__( 'Style 01', 'draly-dropshipping-starter' ),
						'style-02' => esc_html__( 'Style 02', 'draly-dropshipping-starter' ),
					),
					'default'     => 'style-01',
					'label_block' => true
				]
			);
			$this->add_control(
				'background_color',
				[
					'label'     => esc_html__( 'Background Color Button', 'draly-dropshipping-starter' ),
					'type'      => \Elementor\Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .woo-coupon-box-widget .wcbwidget-newsletter-form .wcbwidget-input-group .wcbwidget-input-group-btn .wcbwidget-button' => 'background-color: {{VALUE}}',
					],
				]
			);
			$this->end_controls_section();

		}

		/**
		 * Render the widget output on the frontend.
		 *
		 * Written in PHP and used to generate the final HTML.
		 *
		 * @since 1.0.0
		 *
		 * @access protected
		 */
		protected function render() {
			$atts        = $this->get_settings_for_display();
			$css_class   = array( 'draly-newsletter' );
			$css_class[] = $atts['style'];
			?>
            <div class="<?php echo esc_attr( implode( ' ', $css_class ) ); ?>">
				<?php echo do_shortcode( '[wcb_widget always_visible=1 show_coupon_code=1]' ) ?>
            </div>
			<?php
		}
	}
}