<?php
/**
 * Elementor Newsletter Widget.
 *
 * Elementor widget that inserts an embbedable content into the page, from any given URL.
 *
 * @since 1.0.5
 */
class Elementor_Newsletter_Widget extends \Elementor\Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve Newsletter widget name.
	 *
	 * @since 1.0.5
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'newsletter';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Newsletter widget title.
	 *
	 * @since 1.0.5
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return __( 'Newsletter', 'endless-addons' );
	}

	/**
	 * Get widget icon.
	 *
	 * Retrieve Newsletter widget icon.
	 *
	 * @since 1.0.5
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'fa fa-envelope-o';
	}

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the Newsletter widget belongs to.
	 *
	 * @since 1.0.5
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories() {
		return [ 'endless-elements' ];
	}

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

		$this->start_controls_section(
			'default_section',
			[    
				'label' => __( 'Settings', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT
			]
		);

		$this->add_control(
			'show_newsletter',
			[
				'label' => __( 'Show/Hide Newsletter Section', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::CHOOSE,
				'options' => [
					'show' => [
						'title' => __( 'Show', 'endless-addons' ),
						'icon' => 'fa fa-check'
					],
					'hide' => [
						'title' => __( 'Hide', 'endless-addons' ),
						'icon' => 'fa fa-close'
					]
				],
				'default' => 'show',
				'toggle' => true
			]
		);

		$this->add_control(
			'select_newsletter_style',
			[
				'label' => __( 'Select Newsletter Style', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SELECT,
				'input_type' => 'SELECT',
				'options' => [
					'style-01' => __( 'Style 01', 'endless-addons' ),
					'style-02' => __( 'Style 02', 'endless-addons' ),
					'style-03' => __( 'Style 03', 'endless-addons' ),
					'style-04' => __( 'Style 04', 'endless-addons' ),
					'style-05' => __( 'Style 05', 'endless-addons' ),
					'style-06' => __( 'Style 06', 'endless-addons' ),
					'style-07' => __( 'Style 07', 'endless-addons' )
				],
				'default' => 'style-01'
			]
		);

		$this->add_control(
			'show_newsletter_social',
			[
				'label' => __( 'Show/Hide Newsletter Social', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::CHOOSE,
				'options' => [
					'show' => [
						'title' => __( 'Show', 'endless-addons' ),
						'icon' => 'fa fa-check'
					],
					'hide' => [
						'title' => __( 'Hide', 'endless-addons' ),
						'icon' => 'fa fa-close'
					]
				],
				'default' => 'show',
				'toggle' => true
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'newsletter_section',
			[
				'label' => __( 'Newsletter Section', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);
		
		$this->add_control(
			'newsletter_section_title',
			[
				'label' => __( 'Newsletter Title', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'input_type' => 'text',
				'placeholder' => __( 'Title', 'endless-addons' ),
				'default'  => __( 'Design 1', 'endless-addons' )
			]
		);

		$this->add_control(
			'newsletter_section_desc',
			[
				'label' => __( 'Newsletter Description', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::WYSIWYG,
				'input_type' => 'WYSIWYG',
				'placeholder' => __( 'Description', 'endless-addons' ),
				'default' => __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt dolore magna aliqua. Quis ipsum suspendisse ultrices gravida.', 'endless-addons')
			]
		);

		$this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'section_background',
				'label' => __( 'Background', 'plugin-domain' ),
				'types' => [ 'classic', 'gradient', 'video' ],
				'selector' => '{{WRAPPER}} .ea-newsletter-area',
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'newsletter_content',
			[
				'label' => __( 'Newsletter Content', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);

		$this->add_control(
			'newsletter_title',
			[
				'label' => __( 'Newsletter Title', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'input_type' => 'text',
				'placeholder' => __( 'Title', 'endless-addons' ),
				'default'  => __( 'Subscribe Newsletter', 'endless-addons' )
			]
		);

		$this->add_control(
			'ea_title_tag',
			[
				'label' => __( 'Title Tag', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SELECT,
				'input_type' => 'SELECT',
				'options' => [
					'h1' => __( 'h1', 'endless-addons' ),
					'h2' => __( 'h2', 'endless-addons' ),
					'h3' => __( 'h3', 'endless-addons' ),
					'h4' => __( 'h4', 'endless-addons' ),
					'h5' => __( 'h5', 'endless-addons' ),
					'h6' => __( 'h6', 'endless-addons' )
				],
				'default' => 'h3'
			]
		);

		$this->add_control(
			'newsletter_desc',
			[
				'label' => __( 'Newsletter Description', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::TEXTAREA,
				'input_type' => 'textarea',
				'default' => __( 'Subscribe to the newsletter for all the latest updates', 'endless-addons')
			]
		);

		$this->add_control(
			'newsletter_section_bg_img',
			[
				'label' => __( 'Background Image', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'show_label' => true,
				'condition' => [
                    'select_newsletter_style' => 'style-02'
                ]
			]
		);

		$this->add_control(
            'newsletter_action_url', 
            [
                'label' => esc_html__( 'Action URL', 'endless-addons' ),
                'description' => __( 'Enter here your MailChimp action URL. <a href="https://docs.envytheme.com/docs/endless-addons-plugin-documentation/get-newsletter-form-action-url/" target="_blank"> How to </a>', 'ndless-addons' ),
                'type' => \Elementor\Controls_Manager::TEXT,
                'label_block' => true,
            ]
        );

		$this->add_control(
			'newsletter_placeholder',
			[
				'label' => __( 'Placeholder Text', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'input_type' => 'text',
				'placeholder' => __( 'Placeholder Text', 'endless-addons' ),
				'default'  => __( 'Email address', 'endless-addons' )
			]
		);

		$this->add_control(
			'newsletter_btn_text',
			[
				'label' => __( 'Button Text', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'input_type' => 'text',
				'placeholder' => __( 'Button Text', 'endless-addons' ),
				'default'  => __( 'Subscribe', 'endless-addons' )
			]
		);

		$this->add_control(
			'icon_type',
			[
				'label' => __( 'Icon Type', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SELECT,
				'input_type' => 'SELECT',
				'options' => [
					'general' => __( 'General', 'endless-addons' ),
					'library' => __( 'Library', 'endless-addons' ),
				],
				'default' => 'general'
			]
		);

		$this->add_control(
			'newsletter_btn_icon1', 
			[
				'label' => __( 'Button Icon', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::ICON,
				'input_type' => 'icon',
				'default'  => 'bx bxs-send',
				'show_label' => true,
				'options' => endless_addons_icons(),
				'condition' => [
                    'icon_type' => 'general'
                ]
			]
		);

		$this->add_control(
			'newsletter_btn_icon2', 
			[
				'label' => __( 'Button Icon', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::ICONS,
				'input_type' => 'icon',
				'show_label' => true,
				'options' => endless_addons_icons(),
				'condition' => [
                    'icon_type' => 'library'
                ]
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'newsletter_image',
			[
				'label' => __( 'Newsletter Image', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
				'condition' => [
                    'select_newsletter_style' => array('style-01', 'style-02', 'style-03', 'style-05', 'style-06', 'style-07')
                ]
			]
		);
		
		$this->add_control(
			'newsletter_bg_img',
			[
				'label' => __( 'Content Background Image', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'show_label' => true,
				'condition' => [
                    'select_newsletter_style' => array('style-02', 'style-05', 'style-06')
                ]
			]
		);

		$this->add_control(
			'newsletter_featured_img',
			[
				'label' => __( 'Featured Image', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'show_label' => true,
				'condition' => [
                    'select_newsletter_style' => array('style-01', 'style-05', 'style-07')
                ]
			]
		);

		$this->add_group_control(
			\Elementor\Group_Control_Image_Size::get_type(),
			[
				'name' => 'thumbnail',
				'default' => 'full',
				'separator' => 'none',
				'exclude' => [
					'full',
					'custom',
					'large',
					'shop_catalog',
					'shop_single',
					'shop_thumbnail'
				],
				'condition' => [
					'select_newsletter_style' => array('style-01', 'style-05', 'style-07')
				]
			]
		);

		$this->add_control(
			'newsletter_shape_img1',
			[
				'label' => __( 'Shape Image 1', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'show_label' => true,
				'condition' => [
                    'select_newsletter_style' => 'style-03',
                ]
			]
		);

		$this->add_control(
			'newsletter_shape_img2',
			[
				'label' => __( 'Shape Image 2', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
				'show_label' => true,
				'condition' => [
                    'select_newsletter_style' => 'style-03',
                ]
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'newsletter_social',
			[
				'label' => __( 'Newsletter Social', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);

		$repeater = new \Elementor\Repeater();

		$repeater->add_control(
			'single_social_link', [
				'label' => __( 'Link', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::URL,
				'input_type' => 'url',
				'placeholder' => __( 'Link', 'endless-addons' ),
				'default' => [
					'url' => '#',
					'is_external' => true,
					'nofollow' => true
				]
			]
		);

		$repeater->add_control(
			'single_social_icon', [
				'label' => __( 'Icon', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::ICON,
				'input_type' => 'icon',
				'default'  => 'bx bxl-facebook',
				'show_label' => true,
				'options' => endless_addons_icons()
			]
		);

		$this->add_control(
			'single_newsletter_social',
			[
				'label' => __( 'Single Social', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'default' => [
					[
						'list_title' => __( 'Single Social #1', 'endless-addons' ),
						'list_content' => __( 'Single Social Content', 'endless-addons' ),
					],
				
				],
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'section_style',
			[
				'label' => __( 'Section Style', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE
			]
		);

		$this->add_control(
			'newsletter_bg_color',
			[
				'label' => __( 'Background Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-bg' => 'background: {{VALUE}}'
                ]
			]
		);

		$this->add_control(
			'section_title_color',
			[
				'label' => __( 'Section Title Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-area .section-title h2' => 'color: {{VALUE}}'
                ]
			]
		);

		$this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'section_title_typography',
                'label' => __( 'Section Title Typography', 'endless-addons' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
                'selector' => '{{WRAPPER}} .ea-newsletter-area .section-title h2'
            ]
        );

        $this->add_control(
			'section_desc_color',
			[
				'label' => __( 'Section Description Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-area .section-title p' => 'color: {{VALUE}}'
                ]
			]
		);

		$this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'section_desc_typography',
                'label' => __( 'Section Description Typography', 'endless-addons' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
                'selector' => '{{WRAPPER}} .ea-newsletter-area .section-title p'
            ]
        );

		$this->end_controls_section();

		$this->start_controls_section(
			'newsletter_style',
			[
				'label' => __( 'Newsletter Style', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE
			]
		);

        $this->add_control(
			'newsletter_title_color',
			[
				'label' => __( 'Newsletter Title Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-bg .ea-title' => 'color: {{VALUE}}'
                ]
			]
		);

		$this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'newsletter_title_typography',
                'label' => __( 'Newsletter Title Typography', 'endless-addons' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
                'selector' => '{{WRAPPER}} .ea-newsletter-bg .ea-title'
            ]
        );

        $this->add_control(
			'newsletter_desc_color',
			[
				'label' => __( 'Newsletter Description Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-bg p' => 'color: {{VALUE}}'
                ]
			]
		);

        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'newsletter_desc_typography',
                'label' => __( 'Newsletter Description Typography', 'endless-addons' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
                'selector' => '{{WRAPPER}} .ea-newsletter-bg p'
            ]
        );

        $this->add_control(
			'newsletter_placeholder_color',
			[
				'label' => __( 'Form Placeholder Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-bg input::placeholder' => 'color: {{VALUE}} !important'
                ]
			]
		);

        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'newsletter_placeholder_typography',
                'label' => __( 'Form Placeholder Typography', 'endless-addons' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
                'selector' => '{{WRAPPER}} .ea-newsletter-bg input::placeholder'
            ]
        );

		$this->end_controls_section();

		$this->start_controls_section(
			'newsletter_img_style',
			[
				'label' => __( 'Image Style', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE,
				'condition' => [
                    'select_newsletter_style' => array('style-01', 'style-05', 'style-07')
                ]
			]
		);

        $this->add_control(
			'newsletter_img_height',
			[
				'label' => __( 'Featured Image Height', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'range' => [
					'px' => [
						'min' => 50,
						'max' => 500
					]
				],
				'selectors' => [
					'{{WRAPPER}} .ea-newsletter-area .ea-newsletter-img img, .ea-newsletter-area .ea-newsletter-img-two img' => 'height: {{SIZE}}{{UNIT}}',
				]
			]
		);

		$this->add_control(
			'cnewsletter_img_width',
			[
				'label' => __( 'Featured Image Width', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'range' => [
					'px' => [
						'min' => 50,
						'max' => 500
					]
				],
				'selectors' => [
					'{{WRAPPER}} .ea-newsletter-area .ea-newsletter-img img, .ea-newsletter-area .ea-newsletter-img-two img' => 'width: {{SIZE}}{{UNIT}}',
				],
			]
		);

		$this->add_control(
            'newsletter_img_border_radius',
            [
                'label' => __( 'Image Border Radius', 'endless-addons' ),
                'type' => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => [ 'px', '%' ],
                'separator' => 'after',
                'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-area .ea-newsletter-img img, .ea-newsletter-area .ea-newsletter-img-two img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

		$this->end_controls_section();

		$this->start_controls_section(
			'newsletter_button_style',
			[
				'label' => __( 'Button Style', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE
			],
		);

		$this->add_control(
			'button_bg_color',
			[
				'label' => __( 'Button Background Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-bg .subscribe-btn' => 'background: {{VALUE}}'
                ],
			]
		);

		$this->add_control(
			'button_color',
			[
				'label' => __( 'Button Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-bg .subscribe-btn' => 'color: {{VALUE}}'
                ],
			]
		);

		$this->add_control(
			'button_bg_hover_color',
			[
				'label' => __( 'Button Background Hover Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-bg .subscribe-btn:hover, .ea-newsletter-bg .subscribe-btn:hover::before' => 'background: {{VALUE}}'
                ],
			]
		);

		$this->add_control(
			'button_hover_color',
			[
				'label' => __( 'Button Hover Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-newsletter-bg .subscribe-btn:hover' => 'color: {{VALUE}}'
                ],
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'parallax_style',
			[
				'label' => __( 'Background Parallax', 'endless-addons' ),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE,
				'condition' => [
                    'select_newsletter_style' => array('style-02', 'style-06'),
               ]
			]
		);

		$this->add_control(
			'enable_parallax',
			[
				'label' => __( 'Enable Parallax', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'Yes', 'endless-addons' ),
				'label_off' => __( 'No', 'endless-addons' ),
				'return_value' => 'yes',
				'default' => 'no',
			]
		);

		$this->end_controls_section();

		require plugin_dir_path( dirname( __FILE__ ) ) . 'floating/ea-newsletter-floating.php';

	}

	/**
	 * Render Newsletter widget output on the frontend.
	 *
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since 1.0.5
	 * @access protected
	 */
	protected function render() {

		$settings = $this->get_settings_for_display(); 

		if( $settings['show_newsletter'] == 'show' ) :

			if( $settings['select_newsletter_style'] == 'style-01' ) : ?>
				<!-- Start Newsletter Design One Area -->
				<section class="ea-newsletter-area">
		            <div class="container">
		                <div class="section-title">
		                    <h2><?php echo esc_html__($settings['newsletter_section_title']); ?></h2>
		                    <p><?php echo wp_kses_post($settings['newsletter_section_desc']); ?></p>
		                </div>
		            </div>
		            <div class="ea-newsletter-bg ptb-100">
		                <div class="container">
		                    <div class="row align-items-center">
		                        <div class="col-lg-6">
		                            <<?php echo esc_attr($settings['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($settings['newsletter_title']); ?></<?php echo esc_attr($settings['ea_title_tag']); ?>>
		                            <p><?php echo wp_kses_post($settings['newsletter_desc']); ?></p>
		                            <form class="mailchimp ea-newsletter-form" method="post">
		                                <input type="email" class="form-control" placeholder="<?php echo esc_attr($settings['newsletter_placeholder']); ?>">
		                                <button class="subscribe-btn" type="submit">
		                                    <?php echo esc_attr( $settings['newsletter_btn_text'] ); ?>
		                                    <?php if( $settings['icon_type'] == 'general' ) : ?>
		                                	    <i class="<?php echo wp_kses_post( $settings['newsletter_btn_icon1'] ); ?>"></i>
		                                	<?php else: 
		                                		endad_render_icon( $settings, 'icon', 'newsletter_btn_icon2' ); 
		                                	endif; ?>
		                                </button>
		                                <p class="mchimp-errmessage" style="display: none;"></p>
	                                    <p class="mchimp-sucmessage" style="display: none;"></p>
		                            </form>
		                            <?php if( $settings['show_newsletter_social'] == 'show' ) : ?>	
			                            <ul class="ea-social-icon">
			                            	<?php foreach ( $settings['single_newsletter_social'] as $item ) : 
			                            		$target = $item['single_social_link']['is_external'] ? ' target="_blank"' : '';
		                                        $nofollow = $item['single_social_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
				                                <li>
				                                    <a href="<?php echo esc_url( $item['single_social_link']['url'] ); ?>" <?php echo wp_kses_post( $target ); ?> <?php echo wp_kses_post( $nofollow ); ?>>
				                                        <i class='<?php echo esc_attr( $item['single_social_icon'] ); ?>'></i>
				                                    </a>
				                                </li>
			                                <?php endforeach; ?>
			                            </ul>
			                        <?php endif; ?>
		                        </div>
		                        <div class="col-lg-6">
		                            <div class="ea-newsletter-img ea-mt-30 ea-elementor-floating">
		                                <?php if( ! $settings['newsletter_featured_img']['url'] == '' ) : echo \Elementor\Group_Control_Image_Size::get_attachment_image_html( $settings, 'thumbnail', 'newsletter_featured_img' ); ?>
				                        <?php endif; ?>
		                            </div>
		                        </div>
		                    </div>
		                </div>
		            </div>
		        </section>
		        <!-- End Newsletter Design One Area -->
		    <?php elseif( $settings['select_newsletter_style'] == 'style-02' ) : ?>
				<!-- Start Newsletter Design Two Area -->
				<section class="ea-newsletter-area ptb-100">
		            <div class="container">
		                <div class="section-title">
		                    <h2><?php echo esc_html__($settings['newsletter_section_title']); ?></h2>
		                    <p><?php echo wp_kses_post($settings['newsletter_section_desc']); ?></p>
		                </div>
		            </div>
		            <div class="ea-newsletter-bg style-two ea-elementor-floating" style="background-image:url(<?php echo esc_url( $settings['newsletter_bg_img']['url'] ); ?>);">
		                <div class="container">
		                    <div class="row justify-content-end">
		                        <div class="col-lg-6">
		                        	<div class="ea-thumb-bg ptb-100">
			                            <<?php echo esc_attr($settings['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($settings['newsletter_title']); ?></<?php echo esc_attr($settings['ea_title_tag']); ?>>
			                            <p><?php echo wp_kses_post($settings['newsletter_desc']); ?></p>
			                            <form class="mailchimp ea-newsletter-form style-two" method="post">
			                                <input type="email" class="form-control" placeholder="<?php echo esc_attr($settings['newsletter_placeholder']); ?>">
			                                <button class="subscribe-btn" type="submit">
			                                    <?php echo esc_attr( $settings['newsletter_btn_text'] ); ?>
			                                    <?php if( $settings['icon_type'] == 'general' ) : ?>
			                                	    <i class="<?php echo wp_kses_post( $settings['newsletter_btn_icon1'] ); ?>"></i>
			                                	<?php else: 
			                                		endad_render_icon( $settings, 'icon', 'newsletter_btn_icon2' ); 
			                                	endif; ?>
			                                </button>
			                                <p class="mchimp-errmessage" style="display: none;"></p>
		                                    <p class="mchimp-sucmessage" style="display: none;"></p>
			                            </form>
			                            <?php if( $settings['show_newsletter_social'] == 'show' ) : ?>	
				                            <ul class="ea-social-icon style-two">
				                            	<?php foreach ( $settings['single_newsletter_social'] as $item ) : 
				                            		$target = $item['single_social_link']['is_external'] ? ' target="_blank"' : '';
			                                        $nofollow = $item['single_social_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
					                                <li>
					                                    <a href="<?php echo esc_url( $item['single_social_link']['url'] ); ?>" <?php echo wp_kses_post( $target ); ?> <?php echo wp_kses_post( $nofollow ); ?>>
					                                        <i class='<?php echo esc_attr( $item['single_social_icon'] ); ?>'></i>
					                                    </a>
					                                </li>
				                                <?php endforeach; ?>
				                            </ul>
				                        <?php endif; ?>
				                    </div>
		                        </div>
		                    </div>
		                </div>
		            </div>
		        </section>
		        <style>
		            .ea-newsletter-bg.style-two::before {
		            	background-image: url(<?php echo esc_url( $settings['newsletter_section_bg_img']['url'] ); ?>);
		            }
		        </style>
		        <?php if($settings['enable_parallax'] == 'yes' ){ ?>
			    	<style>
			    		.ea-newsletter-bg.style-two {
			    			background-attachment: fixed;
			    		}
			    	</style>
			    <?php } ?>
		        <!-- End Newsletter Design Two Area -->
		    <?php elseif( $settings['select_newsletter_style'] == 'style-03' ) : ?>
				<!-- Start Newsletter Design Three Area -->
				<section class="ea-newsletter-area pb-100">
		            <div class="container">
		                <div class="section-title">
		                    <h2><?php echo esc_html__($settings['newsletter_section_title']); ?></h2>
		                    <p><?php echo wp_kses_post($settings['newsletter_section_desc']); ?></p>
		                </div>
		            </div>
		            <div class="ea-newsletter-bg style-three">
		                <div class="container">
		                    <div class="row justify-content-center">
		                        <div class="col-lg-8">
		                        	<div class="ea-thumb-bg ptb-100">
			                            <<?php echo esc_attr($settings['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($settings['newsletter_title']); ?></<?php echo esc_attr($settings['ea_title_tag']); ?>>
			                            <p><?php echo wp_kses_post($settings['newsletter_desc']); ?></p>
			                            <form class="mailchimp ea-newsletter-form style-three" method="post">
			                                <input type="email" class="form-control" placeholder="<?php echo esc_attr($settings['newsletter_placeholder']); ?>">
			                                <button class="subscribe-btn" type="submit">
			                                    <?php echo esc_attr( $settings['newsletter_btn_text'] ); ?>
			                                    <?php if( $settings['icon_type'] == 'general' ) : ?>
			                                	    <i class="<?php echo wp_kses_post( $settings['newsletter_btn_icon1'] ); ?>"></i>
			                                	<?php else: 
			                                		endad_render_icon( $settings, 'icon', 'newsletter_btn_icon2' ); 
			                                	endif; ?>
			                                </button>
			                                <p class="mchimp-errmessage" style="display: none;"></p>
		                                    <p class="mchimp-sucmessage" style="display: none;"></p>
			                            </form>
			                            <?php if( $settings['show_newsletter_social'] == 'show' ) : ?>	
				                            <ul class="ea-social-icon style-three">
				                            	<?php foreach ( $settings['single_newsletter_social'] as $item ) : 
				                            		$target = $item['single_social_link']['is_external'] ? ' target="_blank"' : '';
			                                        $nofollow = $item['single_social_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
					                                <li>
					                                    <a href="<?php echo esc_url( $item['single_social_link']['url'] ); ?>" <?php echo wp_kses_post( $target ); ?> <?php echo wp_kses_post( $nofollow ); ?>>
					                                        <i class='<?php echo esc_attr( $item['single_social_icon'] ); ?>'></i>
					                                    </a>
					                                </li>
				                                <?php endforeach; ?>
				                            </ul>
				                        <?php endif; ?>
				                    </div>
		                        </div>
		                    </div>
		                    <div class="shape shape-1">
		                        <?php if( ! $settings['newsletter_shape_img1']['url'] == '' ) : ?>
                                    <img src="<?php echo esc_url( $settings['newsletter_shape_img1']['url'] ); ?>" alt="image">
                                <?php endif; ?>
		                    </div>
		                    <div class="shape shape-2">
		                        <?php if( ! $settings['newsletter_shape_img2']['url'] == '' ) : ?>
                                    <img src="<?php echo esc_url( $settings['newsletter_shape_img2']['url'] ); ?>" alt="image">
                                <?php endif; ?>
		                    </div>
		                </div>
		            </div>
		        </section>
		        <!-- End Newsletter Design Three Area -->
		    <?php elseif( $settings['select_newsletter_style'] == 'style-04' ) : ?>
				<!-- Start Newsletter Design Four Area -->
				<section class="ea-newsletter-area">
		            <div class="container">
		                <div class="section-title">
		                    <h2><?php echo esc_html__($settings['newsletter_section_title']); ?></h2>
		                    <p><?php echo wp_kses_post($settings['newsletter_section_desc']); ?></p>
		                </div>
		            </div>
		            <div class="ea-newsletter-bg style-four ptb-100">
		                <div class="container">
		                    <div class="row align-items-center">
		                        <div class="col-lg-3">
		                        	<p><?php echo wp_kses_post($settings['newsletter_desc']); ?></p>
		                            <<?php echo esc_attr($settings['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($settings['newsletter_title']); ?></<?php echo esc_attr($settings['ea_title_tag']); ?>>
		                        </div>
	                            <div class="col-lg-6">
		                            <form class="mailchimp ea-newsletter-form style-four" method="post">
		                                <input type="email" class="form-control" placeholder="<?php echo esc_attr($settings['newsletter_placeholder']); ?>">
		                                <button class="subscribe-btn" type="submit">
		                                    <?php echo esc_attr( $settings['newsletter_btn_text'] ); ?>
		                                    <?php if( $settings['icon_type'] == 'general' ) : ?>
		                                	    <i class="<?php echo wp_kses_post( $settings['newsletter_btn_icon1'] ); ?>"></i>
		                                	<?php else: 
		                                		endad_render_icon( $settings, 'icon', 'newsletter_btn_icon2' ); 
		                                	endif; ?>
		                                </button>
		                                <p class="mchimp-errmessage" style="display: none;"></p>
	                                    <p class="mchimp-sucmessage" style="display: none;"></p>
		                            </form>
		                        </div>
	                            <?php if( $settings['show_newsletter_social'] == 'show' ) : ?>	
	                            	<div class="col-lg-3">
			                            <ul class="ea-social-icon style-four">
			                            	<?php foreach ( $settings['single_newsletter_social'] as $item ) : 
			                            		$target = $item['single_social_link']['is_external'] ? ' target="_blank"' : '';
		                                        $nofollow = $item['single_social_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
				                                <li>
				                                    <a href="<?php echo esc_url( $item['single_social_link']['url'] ); ?>" <?php echo wp_kses_post( $target ); ?> <?php echo wp_kses_post( $nofollow ); ?>>
				                                        <i class='<?php echo esc_attr( $item['single_social_icon'] ); ?>'></i>
				                                    </a>
				                                </li>
			                                <?php endforeach; ?>
			                            </ul>
			                        </div>
		                        <?php endif; ?>
		                    </div>
		                </div>
		            </div>
		        </section>
		        <!-- End Newsletter Design Four Area -->
		    <?php elseif( $settings['select_newsletter_style'] == 'style-05' ) : ?>
				<!-- Start Newsletter Design Five Area -->
				<section class="ea-newsletter-area ptb-100">
		            <div class="container">
		                <div class="section-title">
		                    <h2><?php echo esc_html__($settings['newsletter_section_title']); ?></h2>
		                    <p><?php echo wp_kses_post($settings['newsletter_section_desc']); ?></p>
		                </div>
		            </div>
		            <div class="ea-newsletter-bg style-five ptb-100" style="background-image:url(<?php echo esc_url( $settings['newsletter_bg_img']['url'] ); ?>);">
		                <div class="container">
		                    <div class="row align-items-center">
		                        <div class="col-lg-6">
		                        	<div class="ea-thumb-bg">
		                        		<<?php echo esc_attr($settings['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($settings['newsletter_title']); ?></<?php echo esc_attr($settings['ea_title_tag']); ?>>
			                        	<p><?php echo wp_kses_post($settings['newsletter_desc']); ?></p>
			                        
			                            <form class="mailchimp ea-newsletter-form style-five" method="post">
			                                <input type="email" class="form-control" placeholder="<?php echo esc_attr($settings['newsletter_placeholder']); ?>">
			                                <button class="subscribe-btn" type="submit">
			                                    <?php echo esc_attr( $settings['newsletter_btn_text'] ); ?>
			                                    <?php if( $settings['icon_type'] == 'general' ) : ?>
			                                	    <i class="<?php echo wp_kses_post( $settings['newsletter_btn_icon1'] ); ?>"></i>
			                                	<?php else: 
			                                		endad_render_icon( $settings, 'icon', 'newsletter_btn_icon2' ); 
			                                	endif; ?>
			                                </button>
			                                <p class="mchimp-errmessage" style="display: none;"></p>
		                                    <p class="mchimp-sucmessage" style="display: none;"></p>
			                            </form>
		                            </div>
		                            <?php if( $settings['show_newsletter_social'] == 'show' ) : ?>	
			                            <ul class="ea-social-icon style-three">
			                            	<?php foreach ( $settings['single_newsletter_social'] as $item ) : 
			                            		$target = $item['single_social_link']['is_external'] ? ' target="_blank"' : '';
		                                        $nofollow = $item['single_social_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
				                                <li>
				                                    <a href="<?php echo esc_url( $item['single_social_link']['url'] ); ?>" <?php echo wp_kses_post( $target ); ?> <?php echo wp_kses_post( $nofollow ); ?>>
				                                        <i class='<?php echo esc_attr( $item['single_social_icon'] ); ?>'></i>
				                                    </a>
				                                </li>
			                                <?php endforeach; ?>
			                            </ul>
			                        <?php endif; ?>
		                        </div>
		                        <div class="col-lg-6">
		                        	<div class="ea-newsletter-img-two text-center ea-mt-30 ea-elementor-floating">
		                        		<?php if( ! $settings['newsletter_featured_img']['url'] == '' ) : echo \Elementor\Group_Control_Image_Size::get_attachment_image_html( $settings, 'thumbnail', 'newsletter_featured_img' ); ?>
				                        <?php endif; ?>
		                        	</div>
			                    </div>
		                    </div>
		                </div>
		            </div>
		        </section>
		        <!-- End Newsletter Design Five Area -->
		    <?php elseif( $settings['select_newsletter_style'] == 'style-06' ) : ?>
				<!-- Start Newsletter Design Six Area -->
				<section class="ea-newsletter-area pb-100">
		            <div class="container">
		                <div class="section-title">
		                    <h2><?php echo esc_html__($settings['newsletter_section_title']); ?></h2>
		                    <p><?php echo wp_kses_post($settings['newsletter_section_desc']); ?></p>
		                </div>
		            </div>
		            <div class="ea-newsletter-bg style-six ptb-100" style="background-image:url(<?php echo esc_url( $settings['newsletter_bg_img']['url'] ); ?>);">
		                <div class="container">
		                    <div class="row justify-content-center">
		                        <div class="col-lg-6">
		                        	<div class="ea-thumb-bg">
		                        		<<?php echo esc_attr($settings['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($settings['newsletter_title']); ?></<?php echo esc_attr($settings['ea_title_tag']); ?>>
			                        	<p><?php echo wp_kses_post($settings['newsletter_desc']); ?></p>
			                        
			                            <form class="mailchimp ea-newsletter-form style-six" method="post">
			                                <input type="email" class="form-control" placeholder="<?php echo esc_attr($settings['newsletter_placeholder']); ?>">
			                                <button class="subscribe-btn" type="submit">
			                                    <?php echo esc_attr( $settings['newsletter_btn_text'] ); ?>
			                                    <?php if( $settings['icon_type'] == 'general' ) : ?>
			                                	    <i class="<?php echo wp_kses_post( $settings['newsletter_btn_icon1'] ); ?>"></i>
			                                	<?php else: 
			                                		endad_render_icon( $settings, 'icon', 'newsletter_btn_icon2' ); 
			                                	endif; ?>
			                                </button>
			                                <p class="mchimp-errmessage" style="display: none;"></p>
		                                    <p class="mchimp-sucmessage" style="display: none;"></p>
			                            </form>
		                            </div>
		                            <?php if( $settings['show_newsletter_social'] == 'show' ) : ?>	
			                            <ul class="ea-social-icon style-three">
			                            	<?php foreach ( $settings['single_newsletter_social'] as $item ) : 
			                            		$target = $item['single_social_link']['is_external'] ? ' target="_blank"' : '';
		                                        $nofollow = $item['single_social_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
				                                <li>
				                                    <a href="<?php echo esc_url( $item['single_social_link']['url'] ); ?>" <?php echo wp_kses_post( $target ); ?> <?php echo wp_kses_post( $nofollow ); ?>>
				                                        <i class='<?php echo esc_attr( $item['single_social_icon'] ); ?>'></i>
				                                    </a>
				                                </li>
			                                <?php endforeach; ?>
			                            </ul>
			                        <?php endif; ?>
		                        </div>
		                    </div>
		                </div>
		            </div>
		        </section>
		        <!-- End Newsletter Design Six Area -->
		        <?php if($settings['enable_parallax'] == 'yes' ){ ?>
			    	<style>
			    		.ea-newsletter-bg.style-six {
			    			background-attachment: fixed;
			    		}
			    	</style>
			    <?php } ?>
		    <?php elseif( $settings['select_newsletter_style'] == 'style-07' ) : ?>
				<!-- Start Newsletter Design Seven Area -->
				<section class="ea-newsletter-area style-seven bg-shape">
		            <div class="container">
		                <div class="section-title">
		                    <h2><?php echo esc_html__($settings['newsletter_section_title']); ?></h2>
		                    <p><?php echo wp_kses_post($settings['newsletter_section_desc']); ?></p>
		                </div>
		            </div>
		            <div class="ea-newsletter-bg style-seven ptb-100">
		                <div class="container">
		                    <div class="row align-items-center">
		                    	<div class="col-lg-6">
		                        	<div class="ea-newsletter-img-two text-center ea-mt-30 ea-elementor-floating">
		                        		<?php if( ! $settings['newsletter_featured_img']['url'] == '' ) : echo \Elementor\Group_Control_Image_Size::get_attachment_image_html( $settings, 'thumbnail', 'newsletter_featured_img' ); ?>
				                        <?php endif; ?>
		                        	</div>
			                    </div>
		                        <div class="col-lg-6">
		                        	<div class="ea-thumb-bg">
		                        		<<?php echo esc_attr($settings['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($settings['newsletter_title']); ?></<?php echo esc_attr($settings['ea_title_tag']); ?>>
			                        	<p><?php echo wp_kses_post($settings['newsletter_desc']); ?></p>
			                            <form class="mailchimp ea-newsletter-form style-seven" method="post">
			                                <input type="email" class="form-control" placeholder="<?php echo esc_attr($settings['newsletter_placeholder']); ?>">
			                                <button class="subscribe-btn" type="submit">
			                                    <?php echo esc_attr( $settings['newsletter_btn_text'] ); ?>
			                                    <?php if( $settings['icon_type'] == 'general' ) : ?>
			                                	    <i class="<?php echo wp_kses_post( $settings['newsletter_btn_icon1'] ); ?>"></i>
			                                	<?php else: 
			                                		endad_render_icon( $settings, 'icon', 'newsletter_btn_icon2' ); 
			                                	endif; ?>
			                                </button>
			                                <p class="mchimp-errmessage" style="display: none;"></p>
		                                    <p class="mchimp-sucmessage" style="display: none;"></p>
			                            </form>
		                            </div>
		                            <?php if( $settings['show_newsletter_social'] == 'show' ) : ?>	
			                            <ul class="ea-social-icon style-seven">
			                            	<?php foreach ( $settings['single_newsletter_social'] as $item ) : 
			                            		$target = $item['single_social_link']['is_external'] ? ' target="_blank"' : '';
		                                        $nofollow = $item['single_social_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
				                                <li>
				                                    <a href="<?php echo esc_url( $item['single_social_link']['url'] ); ?>" <?php echo wp_kses_post( $target ); ?> <?php echo wp_kses_post( $nofollow ); ?>>
				                                        <i class='<?php echo esc_attr( $item['single_social_icon'] ); ?>'></i>
				                                    </a>
				                                </li>
			                                <?php endforeach; ?>
			                            </ul>
			                        <?php endif; ?>
		                        </div>
		                    </div>
		                </div>
		            </div>
		        </section>
		        <!-- End Newsletter Design Seven Area -->
	        <?php endif;

        endif; ?>

        <script>
                ;(function($){
                    "use strict";
                    $(document).ready(function () {
                        // MAILCHIMP
                        if ($(".mailchimp").length > 0) {
                            $(".mailchimp").ajaxChimp({
                                callback: mailchimpCallback,
                                url: "<?php echo esc_js($settings['newsletter_action_url']) ?>"
                            });
                        }
                        $(".memail").on("focus", function () {
                            $(".mchimp-errmessage").fadeOut();
                            $(".mchimp-sucmessage").fadeOut();
                        });
                        $(".memail").on("keydown", function () {
                            $(".mchimp-errmessage").fadeOut();
                            $(".mchimp-sucmessage").fadeOut();
                        });
                        $(".memail").on("click", function () {
                            $(".memail").val("");
                        });

                        function mailchimpCallback(resp) {
                            if (resp.result === "success") {
                                $(".mchimp-errmessage").html(resp.msg).fadeIn(1000);
                                $(".mchimp-sucmessage").fadeOut(500);
                            } else if (resp.result === "error") {
                                $(".mchimp-errmessage").html(resp.msg).fadeIn(1000);
                            }
                        }
                    });
                })(jQuery)
            </script>

        <?php
    }

}
