<?php
/**
 * Elementor Image Box Widget.
 *
 * Elementor widget that inserts an embbedable content into the page, from any given URL.
 *
 * @since 1.0.5
 */

use \Elementor\Plugin;

class Elementor_Imagebox_Widget extends \Elementor\Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve Image Box widget name.
	 *
	 * @since 1.0.5
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'image-box';
	}

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

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

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

	/**
	 * Register Image Box 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_imagebox',
			[
				'label' => __( 'Show/Hide Image Box 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_imagebox_style',
			[
				'label' => __( 'Select Image Box 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' ),
					'style-08' => __( 'Style 08', 'endless-addons' )
				],
				'default' => 'style-01'
			]
		);

		$this->end_controls_section();

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

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

		$this->add_control(
			'section_desc',
			[
				'label' => __( 'Section 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-image-box-area',
			]
		);

		$this->end_controls_section();

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

		$this->add_control(
			'imagebox_item_column',
			[
				'label' => __( 'Select Imagebox Column', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SELECT,
				'input_type' => 'SELECT',
				'options' => [
					'columns-2' => __( '2', 'endless-addons' ),
					'columns-3' => __( '3', 'endless-addons' ),
					'columns-4' => __( '4', 'endless-addons' )
				],
				'default' => 'columns-3',
				'condition' => [
                    'select_imagebox_style' => array('style-01', 'style-02', 'style-03', 'style-05', 'style-06', 'style-07', 'style-08')
                ]
			]
		);

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

		$this->add_control(
            'imagebox_img_v_alignment',
            [
                'label' => esc_html__('Image Vertical Alignment', 'endless-addons'),
                'type' => \Elementor\Controls_Manager::CHOOSE,
                'label_block' => true,
                'options' => [
                    'top' => [
                        'title' => __('Top', 'endless-addons'),
                        'icon' => 'eicon-v-align-top',
                    ],
                    'bottom' => [
                        'title' => __('Bottom', 'endless-addons'),
                        'icon' => 'eicon-v-align-bottom',
                    ],
                ],
                'default' => 'top',
                'condition' => [
                    'select_imagebox_style' => array('style-01', 'style-02', 'style-03', 'style-05', 'style-08')
                ]
            ]
        );

        $this->add_control(
            'imagebox_img_h_alignment',
            [
                'label' => esc_html__('Image Horizontal Alignment', 'endless-addons'),
                'type' => \Elementor\Controls_Manager::CHOOSE,
                'label_block' => true,
                'options' => [
                    'left' => [
                        'title' => esc_html__('Left', 'endless-addons'),
                        'icon' => 'fa fa-align-left',
                    ],
                    'center' => [
                        'title' => esc_html__('Center', 'endless-addons'),
                        'icon' => 'fa fa-align-center',
                    ],
                    'right' => [
                        'title' => esc_html__('Right', 'endless-addons'),
                        'icon' => 'fa fa-align-right',
                    ],
                ]
            ]
        );

        $this->add_control(
            'imagebox_content_h_alignment',
            [
                'label' => esc_html__('Content Horizontal Alignment', 'endless-addons'),
                'type' => \Elementor\Controls_Manager::CHOOSE,
                'label_block' => true,
                'options' => [
                    'left' => [
                        'title' => esc_html__('Left', 'endless-addons'),
                        'icon' => 'fa fa-align-left',
                    ],
                    'center' => [
                        'title' => esc_html__('Center', 'endless-addons'),
                        'icon' => 'fa fa-align-center',
                    ],
                    'right' => [
                        'title' => esc_html__('Right', 'endless-addons'),
                        'icon' => 'fa fa-align-right',
                    ],
                ]
            ]
        );


		$repeater = new \Elementor\Repeater();

		$repeater->add_control(
			'single_imagebox_image', [
				'label' => __( 'Image', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::MEDIA,
                'show_label' => true,
			]
		);

		$repeater->add_control(
            'single_show_img_link',
            [
                'label' => __( 'Show Image Link', 'endless-addons' ),
                'type' => \Elementor\Controls_Manager::SWITCHER,
                'label_on' => __( 'Yes', 'endless-addons' ),
                'label_off' => __( 'No', 'endless-addons' ),
                'return_value' => 'yes',
                'default' => 'no'
            ]
        );

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

		$repeater->add_control(
			'single_imagebox_title', [
				'label' => __( 'Title', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::TEXT,
				'input_type' => 'text',
				'placeholder' => __( 'Title', 'endless-addons' ),
				'default'  => __( 'Your Heading Title', 'endless-addons' )
			]
		);

		$repeater->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'
			]
		);

		$repeater->add_control(
            'ea_content_text_type',
            [
                'label' => __('Content Type', 'endless-addons'),
                'type' => \Elementor\Controls_Manager::SELECT,
                'options' => [
                    'content' => __('Content', 'endless-addons'),
                    'template' => __('Saved Templates', 'endless-addons'),
                ],
                'default' => 'content',
            ]
        );

		$repeater->add_control(
			'single_imagebox_desc', [
				'label' => __( 'Description', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::TEXTAREA,
				'input_type' => 'textarea',
				'placeholder' => __( 'Description', 'endless-addons' ),
				'default'  => __( 'Lorem ipsum dolor sit amet, consectetur Risus commodo viverra maecenas...', 'endless-addons' ),
				'condition' => [
                    'ea_content_text_type' => 'content'
                ]
			]
		);

		$repeater->add_control(
            'ea_content_templates',
            [
                'label' => __('Choose Template', 'endless-addons'),
                'type' => \Elementor\Controls_Manager::SELECT,
                'options' => ea_get_elementor_templates(),
                'condition' => [
                    'ea_content_text_type' => 'template',
                ],
            ]
        );

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

		$this->add_control(
			'show_image_caption',
			[
				'label' => __( 'Show/Hide Image Caption', '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'
					]
				],
				'description' => __( 'Make sure to add image caption.', 'endless-addons' ),
				'default' => 'hide',
				'toggle' => true
			]
		);

		$this->end_controls_section();

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

		$this->add_control(
			'section_title_color',
			[
				'label' => __( 'Section Title Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-image-box-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-image-box-area .section-title h2'
            ]
        );

        $this->add_control(
			'section_desc_color',
			[
				'label' => __( 'Section Description Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-image-box-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-image-box-area .section-title p'
            ]
        );

		$this->end_controls_section();

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

		$this->add_control(
			'imagebox_image_height',
			[
				'label' => __( 'Height', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'range' => [
					'px' => [
						'min' => 100,
						'max' => 1000
					]
				],
				'selectors' => [
					'{{WRAPPER}} .ea-image-box-area .single-image-box img, .ea-image-box-area .ea-image-box img' => 'height: {{SIZE}}{{UNIT}}',
				],
			]
		);

		$this->add_control(
			'imagebox_image_width',
			[
				'label' => __( 'Width', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'range' => [
					'px' => [
						'min' => 100,
						'max' => 1000
					]
				],
				'selectors' => [
					'{{WRAPPER}} .ea-image-box-area .single-image-box img, .ea-image-box-area .ea-image-box img' => 'width: {{SIZE}}{{UNIT}}',
				],
			]
		);

		$this->add_control(
            'imagebox_image_padding',
            [
                'label'         => esc_html__( 'Padding', 'endless-addons' ),
                'type'          => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units'    => [ 'px', '%', 'em' ],
                'selectors'     => [
                    '{{WRAPPER}} .ea-image-box-area .single-image-box, .ea-image-box-area .ea-image-box' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

        $this->add_control(
            'imagebox_image_margin',
            [
                'label'         => esc_html__( 'Margin', 'endless-addons' ),
                'type'          => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units'    => [ 'px', '%', 'em' ],
                'selectors'     => [
                    '{{WRAPPER}} .ea-image-box-area .single-image-box, .ea-image-box-area .ea-image-box' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );

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

        $this->add_control(
			'imagebox_caption_color',
			[
				'label' => __( 'Imagebox Caption Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-image-box-area .image-box-content .ea-caption, .ea-image-box-area .card-body p.card-title' => 'color: {{VALUE}}'
                ],
                'condition' => [
                    'show_image_caption' => 'show',
                ],
			]
		);

        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'imagebox_caption_typography',
                'label' => __( 'Imagebox Caption Typography', 'endless-addons' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
                'selector' => '{{WRAPPER}} .ea-image-box-area .image-box-content .ea-caption, .ea-image-box-area .card-body p.card-title',
                'condition' => [
                    'show_image_caption' => 'show',
                ],
            ]
        );

		$this->add_control(
			'imagebox_title_color',
			[
				'label' => __( 'Imagebox Title Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-image-box-area .image-box-content .ea-title, .ea-image-box-area .card-body .card-title' => 'color: {{VALUE}}'
                ]
			]
		);

        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'imagebox_title_typography',
                'label' => __( 'Imagebox Title Typography', 'endless-addons' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
                'selector' => '{{WRAPPER}} .ea-image-box-area .image-box-content .ea-title, .ea-image-box-area .card-body .card-title'
            ]
        );

        $this->add_control(
			'imagebox_desc_color',
			[
				'label' => __( 'Imagebox Description Color', 'endless-addons' ),
				'type' => \Elementor\Controls_Manager::COLOR,
				'selectors' => [
                    '{{WRAPPER}} .ea-image-box-area .image-box-content p, .ea-image-box-area .card-body p.card-text' => 'color: {{VALUE}}'
                ]
			]
		);

        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name' => 'imagebox_desc_typography',
                'label' => __( 'Imagebox Description Typography', 'endless-addons' ),
                'scheme' => \Elementor\Core\Schemes\Typography::TYPOGRAPHY_1,
                'selector' => '{{WRAPPER}} .ea-image-box-area .image-box-content p, .ea-image-box-area .card-body p.card-text'
            ]
        );

		$this->end_controls_section();

		$this->start_controls_section(
			'_section_overlay_style',
			[
				'label' => __('Background Overlay', 'endless-addons'),
				'tab' => \Elementor\Controls_Manager::TAB_STYLE
			]
		);

		$this->start_controls_tabs('_tabs_overlay_style');

		$this->start_controls_tab(
			'_tab_overlay_normal',
			[
				'label' => __('Normal', 'endless-addons'),
			]
		);

		$this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name'     => 'hover_overlay_normal',
				'label' => __('Background', 'endless-addons'),
				'show_label' => true,
				'types' => ['classic', 'gradient'],
				'exclude' => [
					'classic' => 'image'
				],
				'selector' => '{{WRAPPER}} .ea-image-box-area',
			]
		);

		$this->end_controls_tab();

		$this->start_controls_tab(
			'_tab_overlay_hover',
			[
				'label' => __('Hover', 'endless-addons'),
			]
		);


		$this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name'     => 'hover_overlay_hover',
				'label' => __('Background', 'endless-addons'),
				'show_label' => true,
				'types' => ['classic', 'gradient'],
				'exclude' => [
					'classic' => 'image'
				],
				'selector' => '{{WRAPPER}} .ea-image-box-area:hover',
			]
		);

		$this->end_controls_tab();

		$this->end_controls_tabs();

		$this->end_controls_section();

	}

	/**
	 * Render Image Box 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['imagebox_img_h_alignment'] == 'left' ) : 
		    $this->add_render_attribute('img_h_alignment', 'class', 'img-h-alignment img-h-left');
		elseif( $settings['imagebox_img_h_alignment'] == 'center' ) :
            $this->add_render_attribute('img_h_alignment', 'class', 'img-h-alignment img-h-center');
		elseif( $settings['imagebox_img_h_alignment'] == 'right' ) :
            $this->add_render_attribute('img_h_alignment', 'class', 'img-h-alignment img-h-right');
        endif;

        if( $settings['imagebox_content_h_alignment'] == 'left' ) : 
		    $this->add_render_attribute('content_h_alignment', 'class', 'content-h-alignment content-h-left');
		elseif( $settings['imagebox_content_h_alignment'] == 'center' ) :
            $this->add_render_attribute('content_h_alignment', 'class', 'content-h-alignment content-h-center');
		elseif( $settings['imagebox_content_h_alignment'] == 'right' ) :
            $this->add_render_attribute('content_h_alignment', 'class', 'content-h-alignment content-h-right');
        endif; ?>

		<!-- Imagebox Column Style -->
	    <?php if( $settings['imagebox_item_column'] == 'columns-2' ) :
			$imagebox_column = 'col-lg-6 col-md-6 col-sm-6';
		elseif( $settings['imagebox_item_column'] == 'columns-3' ) :
			$imagebox_column = 'col-lg-4 col-md-6 col-sm-6';
		elseif( $settings['imagebox_item_column'] == 'columns-4' ) :
			$imagebox_column = 'col-lg-3 col-md-6 col-sm-6';
		endif;

		if( $settings['select_imagebox_style'] == 'style-01' ) : 
			$ea_image_box_area = 'pb-70';
			$ea_image_box_container = 'container';
			$ea_image_box_p_0 = '';
			$single_image_box  = 'single-image-box';
	    elseif( $settings['select_imagebox_style'] == 'style-02' ) :
            $ea_image_box_area = 'bg-color-f6ede8 pt-100 pb-70';
            $ea_image_box_container = 'container';
            $ea_image_box_p_0 = '';
            $single_image_box  = 'single-image-box style-two';
	    elseif( $settings['select_imagebox_style'] == 'style-03' ) :
            $ea_image_box_area = 'pt-100 pb-70';
            $ea_image_box_container = 'container';
            $ea_image_box_p_0 = '';
            $single_image_box  = 'single-image-box style-three';
	    elseif( $settings['select_imagebox_style'] == 'style-04' ) :
            $ea_image_box_area = 'pb-70';
            $ea_image_box_container = 'container';
            $ea_image_box_p_0 = '';
            $single_image_box  = 'single-image-box';
	    elseif( $settings['select_imagebox_style'] == 'style-05' ) :
            $ea_image_box_area = 'bg-color-fffae9 pt-100 pb-70';
            $ea_image_box_container = 'container';
            $ea_image_box_p_0 = '';
            $single_image_box  = 'single-image-box style-five';
	    elseif( $settings['select_imagebox_style'] == 'style-06' ) :
            $ea_image_box_area = 'bg-color-fffae9 pb-70';
            $ea_image_box_container = 'container';
            $ea_image_box_p_0 = '';
            $single_image_box  = 'single-image-box style-six';
	    elseif( $settings['select_imagebox_style'] == 'style-07' ) :
            $ea_image_box_area = 'style-seven pt-100 pb-70';
            $ea_image_box_container = 'container-fluid';
            $ea_image_box_p_0 = 'p-0';
            $single_image_box  = 'single-image-box style-seven';
	    elseif( $settings['select_imagebox_style'] == 'style-08' ) :
            $ea_image_box_area = 'style-eight bg-shape';
            $ea_image_box_container = 'container';
            $ea_image_box_p_0 = '';
            $single_image_box  = 'single-image-box style-eight';
        endif;

		if( $settings['show_imagebox'] == 'show' ) : ?>

			<!-- Start Image Box Design Area -->
	        <section class="ea-image-box-area <?php echo esc_attr($ea_image_box_area); ?>">
	            <div class="<?php echo esc_attr($ea_image_box_container); ?>">
	                <div class="section-title">
	                    <h2><?php echo esc_html($settings['section_title']); ?></h2>
	                    <p><?php echo esc_html($settings['section_desc']); ?></p>
	                </div>
	                <?php if( $settings['select_imagebox_style'] == 'style-04' ) : ?>
	                    <?php foreach ( $settings['single_imagebox'] as $item ) : ?> 
		                	<div class="card">
			                    <div class="row g-0">
			                        <div class="col-md-4">
			                            <div class="ea-image-box">
			                            	<?php if( ! $item['single_imagebox_image']['url'] == '' ) : ?>
				                                <?php if( $item['single_show_img_link'] == 'yes' ) : 
				                                    $target1 = $item['single_img_link']['is_external'] ? ' target="_blank"' : '';
			                                        $nofollow1 = $item['single_img_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
				                                	<a href="<?php echo esc_url( $item['single_img_link']['url'] ); ?>" <?php echo wp_kses_post( $target1 ); ?> <?php echo wp_kses_post( $nofollow1 ); ?>>
						                                <img <?php echo $this->get_render_attribute_string('img_h_alignment'); ?> src="<?php echo esc_url( $item['single_imagebox_image']['url'] ); ?>" alt="image">
					                                </a>
					                            <?php else: ?>
					                            	<img <?php echo $this->get_render_attribute_string('img_h_alignment'); ?> src="<?php echo esc_url( $item['single_imagebox_image']['url'] ); ?>" alt="image">
				                                <?php endif; 
			                                endif; ?>
			                            </div>
			                        </div>
			                    	<div class="col-md-8">
			                    		<div <?php echo $this->get_render_attribute_string('content_h_alignment'); ?>>
				                            <div class="card-body">
				                            	<?php if( $settings['show_image_caption'] == 'show' ) : ?>  
		                                        	<p class="card-title">
		                                                <?php
		                                                $img_caption_url = $item['single_imagebox_image']['url'];
		                                                $img_caption_attachment = attachment_url_to_postid( $img_caption_url );
		                                                echo esc_attr( wp_get_attachment_caption($img_caption_attachment) ); ?>
		                                            </p>
		                                        <?php  endif; ?>
		                                        <<?php echo esc_attr($item['ea_title_tag']); ?> class="card-title"><?php echo esc_html($item['single_imagebox_title']); ?></<?php echo esc_attr($item['ea_title_tag']); ?>>
				                                <?php if($item['ea_content_text_type'] == 'content') : ?>
				                                	<?php if( ! $item['single_imagebox_desc'] == '' ) : ?>
					                                <p class="card-text"><?php echo wp_kses_post($item['single_imagebox_desc']); ?></p>
					                                <?php endif; ?>
					                            <?php elseif($item['ea_content_text_type'] == 'template') : ?>
					                            	<p class="card-text">
					                            		<?php if (!empty($item['ea_content_templates'])) {
											                echo Plugin::$instance->frontend->get_builder_content($item['ea_content_templates'], true);
											            } ?>
					                            	</p>
					                            <?php endif; ?>
				                            </div>
				                        </div>
			                        </div>
			                    </div>
			                </div>
		                <?php endforeach; ?>
		            <?php else: ?>
		                <div class="row justify-content-center">
		                	<?php foreach ( $settings['single_imagebox'] as $item ) : ?>
			                    <div class="imagebox-col <?php echo esc_attr( $imagebox_column ); ?> <?php echo esc_attr($ea_image_box_p_0); ?>">    
			                        <div class="<?php echo esc_attr($single_image_box); ?>">
			                        	<?php if( $settings['imagebox_img_v_alignment'] == 'bottom' ) : ?>
				                            <div class="image-box-content">
				                            	<div <?php echo $this->get_render_attribute_string('content_h_alignment'); ?>>
					                            	<?php if( $settings['show_image_caption'] == 'show' ) : ?> 
			                                        	<p class="ea-caption">
			                                                <?php
			                                                $img_caption_url = $item['single_imagebox_image']['url'];
			                                                $img_caption_attachment = attachment_url_to_postid( $img_caption_url );
			                                                echo esc_attr( wp_get_attachment_caption($img_caption_attachment) ); ?>
			                                            </p>
			                                        <?php  endif; ?>
			                                        <<?php echo esc_attr($item['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($item['single_imagebox_title']); ?></<?php echo esc_attr($item['ea_title_tag']); ?>>
					                                <?php if($item['ea_content_text_type'] == 'content') : ?>
					                                	<?php if( ! $item['single_imagebox_desc'] == '' ) : ?>
						                                <p><?php echo wp_kses_post($item['single_imagebox_desc']); ?></p>
						                                <?php endif; ?>
						                            <?php elseif($item['ea_content_text_type'] == 'template') : ?>
						                            	<p>
						                            		<?php if (!empty($item['ea_content_templates'])) {
												                echo Plugin::$instance->frontend->get_builder_content($item['ea_content_templates'], true);
												            } ?>
						                            	</p>
						                            <?php endif; ?>
					                            </div>
					                        </div>
			                            <?php endif; ?>
			                            <?php if( ! $item['single_imagebox_image']['url'] == '' ) : ?>
			                                <?php if( $item['single_show_img_link'] == 'yes' ) :
			                                	$target2 = $item['single_img_link']['is_external'] ? ' target="_blank"' : '';
			                                    $nofollow2 = $item['single_img_link']['nofollow'] ? ' rel="nofollow"' : ''; ?>
			                                	<a href="<?php echo esc_url( $item['single_img_link']['url'] ); ?>" <?php echo wp_kses_post( $target2 ); ?> <?php echo wp_kses_post( $nofollow2 ); ?>>
					                                <img <?php echo $this->get_render_attribute_string('img_h_alignment'); ?> src="<?php echo esc_url( $item['single_imagebox_image']['url'] ); ?>" alt="image">
				                                </a>
				                            <?php else: ?>
				                            	<img <?php echo $this->get_render_attribute_string('img_h_alignment'); ?> src="<?php echo esc_url( $item['single_imagebox_image']['url'] ); ?>" alt="image">
			                                <?php endif; 
		                                endif; ?>
		                                <?php if( $settings['select_imagebox_style'] == 'style-06' || $settings['select_imagebox_style'] == 'style-07' ) : ?>
			                                <div class="image-box-content">
			                                	<div <?php echo $this->get_render_attribute_string('content_h_alignment'); ?>>
					                            	<?php if( $settings['show_image_caption'] == 'show' ) : ?> 
			                                        	<p class="ea-caption">
			                                                <?php
			                                                $img_caption_url = $item['single_imagebox_image']['url'];
			                                                $img_caption_attachment = attachment_url_to_postid( $img_caption_url );
			                                                echo esc_attr( wp_get_attachment_caption($img_caption_attachment) ); ?>
			                                            </p>
			                                        <?php  endif; ?>
					                                <<?php echo esc_attr($item['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($item['single_imagebox_title']); ?></<?php echo esc_attr($item['ea_title_tag']); ?>>
					                                <?php if($item['ea_content_text_type'] == 'content') : ?>
					                                	<?php if( ! $item['single_imagebox_desc'] == '' ) : ?>
						                                <p><?php echo wp_kses_post($item['single_imagebox_desc']); ?></p>
						                                <?php endif; ?>
						                            <?php elseif($item['ea_content_text_type'] == 'template') : ?>
						                            	<p>
						                            		<?php if (!empty($item['ea_content_templates'])) {
												                echo Plugin::$instance->frontend->get_builder_content($item['ea_content_templates'], true);
												            } ?>
						                            	</p>
						                            <?php endif; ?>
					                            </div>
					                        </div>
			                            <?php endif; ?>
		                                <?php if( $settings['imagebox_img_v_alignment'] == 'top' ) : ?>  
				                            <div class="image-box-content">
				                            	<div <?php echo $this->get_render_attribute_string('content_h_alignment'); ?>>
					                            	<?php if( $settings['show_image_caption'] == 'show' ) : ?> 
			                                        	<p class="ea-caption">
			                                                <?php
			                                                $img_caption_url = $item['single_imagebox_image']['url'];
			                                                $img_caption_attachment = attachment_url_to_postid( $img_caption_url );
			                                                echo esc_attr( wp_get_attachment_caption($img_caption_attachment) ); ?>
			                                            </p>
			                                        <?php  endif; ?>
					                                <<?php echo esc_attr($item['ea_title_tag']); ?> class="ea-title"><?php echo esc_html($item['single_imagebox_title']); ?></<?php echo esc_attr($item['ea_title_tag']); ?>>
					                                <?php if($item['ea_content_text_type'] == 'content') : ?>
					                                	<?php if( ! $item['single_imagebox_desc'] == '' ) : ?>
						                                <p><?php echo wp_kses_post($item['single_imagebox_desc']); ?></p>
						                                <?php endif; ?>
						                            <?php elseif($item['ea_content_text_type'] == 'template') : ?>
						                            	<p>
						                            		<?php if (!empty($item['ea_content_templates'])) {
												                echo Plugin::$instance->frontend->get_builder_content($item['ea_content_templates'], true);
												            } ?>
						                            	</p>
						                            <?php endif; ?>
					                            </div>
					                        </div>
			                            <?php endif; ?>
			                        </div>  
			                    </div>
		                    <?php endforeach; ?>
		                </div>
		            <?php endif; ?>
	            </div>
	            <?php if( $settings['select_imagebox_style'] == 'style-02' && ! $settings['imagebox_shape_image']['url'] == '' ) : ?>
	            	<div class="image-box-shape">
                        <img src="<?php echo esc_url( $settings['imagebox_shape_image']['url'] ); ?>" alt="image">
                    </div>
                <?php endif; ?>
	        </section>
	        <!-- End Image Box Design Area -->
	
        <?php endif;

    }

}
