<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Feron
 * @since 1.0.0
 */ 
 
class Banner_5 extends Widget_Base {

	/**
	 * Get widget name.
	 * Retrieve button widget name.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'feron-banner-5-widget';
	}

	/**
	 * Get widget title.
	 * Retrieve button widget title.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Banner 5', 'feron-core' );
	}

	/**
	 * Get widget icon.
	 * Retrieve button widget icon.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'eicon-flash';
	}

	/**
	 * Get widget categories.
	 * Retrieve the list of categories the button widget belongs to.
	 * Used to determine where to display the widget in the editor.
	 *
	 * @since  2.0.0
	 * @access public
	 * @return array Widget categories.
	 */
	public function get_categories()
    {
        return ['feron_widgets'];
    }
	
	/**
	 * Register button 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(
			'banner_images_section',
			[
				'label' => esc_html__( 'Banner Images', 'feron-core' ),
			]
		);	
		
		$this->add_control(
			'image',
			[
				'label' => esc_html__( 'Banner Image', 'feron-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);

		$this->add_control(
			'image2',
			[
				'label' => esc_html__( 'Banner Image 2', 'feron-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);

		$this->add_control(
			'image3',
			[
				'label' => esc_html__( 'Banner Image 3', 'feron-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);

		$this->add_control(
			'image4',
			[
				'label' => esc_html__( 'Banner Image 4', 'feron-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);

		$this->add_control(
			'image5',
			[
				'label' => esc_html__( 'Banner Image 5', 'feron-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);

		$this->add_control(
			'image6',
			[
				'label' => esc_html__( 'Banner Image 6', 'feron-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);

		$this->add_control(
			'bg_image',
			[
				'label' => esc_html__( 'Background Image', 'feron-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);

		$this->end_controls_section();


		$this->start_controls_section(
			'banner_content',
			[
				'label' => esc_html__( 'Banner Content', 'feron-core' ),
			]
		);	

			
		$this->add_control(
			'subtitle',
			[
				'label' => esc_html__( 'Subtitle', 'feron-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Welcome to Feron', 'feron-core' ),
			]
		);

		$this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'feron-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Discover Amazing Places', 'feron-core' ),
			]
		);

		$this->add_control(
			'text',
			[
				'label' => esc_html__( 'Text', 'feron-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'feron-core' ),
			]
		);

		$this->add_control(
			'button',
			[
				'label' => esc_html__( 'Button Text', 'feron-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Get Started', 'feron-core' ),
			]
		);

		$this->add_control(
			'button_link',
			[
				'label' => esc_html__( 'Button Link', 'feron-core' ),
				'type' => Controls_Manager::URL,
				'default' => [
					'url' => '#',
				],
			]
		);

		$this->add_control(
			'button2',
			[
				'label' => esc_html__( 'Button 2 Text', 'feron-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Get Started', 'feron-core' ),
			]
		);

		$this->add_control(
			'button_link2',
			[
				'label' => esc_html__( 'Button 2 Link', 'feron-core' ),
				'type' => Controls_Manager::URL,
				'default' => [
					'url' => '#',
				],
			]
		);


		$this->end_controls_section();

	
		}

	/**
	 * Render button widget output on the frontend.
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function render() {
		$settings = $this->get_settings_for_display();
		$allowed_tags = wp_kses_allowed_html('post');
		?>	

		<div class="hero-section hero-7 fix bg-cover" style="background-image: url(<?php echo wp_get_attachment_url($settings['bg_image']['id']);?>);">
            <div class="left-image wow img-custom-anim-left">
                <?php  if ( !empty(esc_url($settings['image']['id']) )) : ?>   
					<img src="<?php echo wp_get_attachment_url($settings['image']['id']);?>" alt=""/>
				<?php endif;?>
            </div>
             <div class="left-image-2 wow img-custom-anim-right">
                <?php  if ( !empty(esc_url($settings['image2']['id']) )) : ?>   
					<img src="<?php echo wp_get_attachment_url($settings['image2']['id']);?>" alt=""/>
				<?php endif;?>
            </div>
             <div class="right-image wow img-custom-anim-right">
                <?php  if ( !empty(esc_url($settings['image3']['id']) )) : ?>   
					<img src="<?php echo wp_get_attachment_url($settings['image3']['id']);?>" alt=""/>
				<?php endif;?>
            </div>
            <div class="right-image-2 wow img-custom-anim-left">
                <?php  if ( !empty(esc_url($settings['image4']['id']) )) : ?>   
					<img src="<?php echo wp_get_attachment_url($settings['image4']['id']);?>" alt=""/>
				<?php endif;?>
            </div>
            <div class="blur-shape">
                <?php  if ( !empty(esc_url($settings['image5']['id']) )) : ?>   
					<img src="<?php echo wp_get_attachment_url($settings['image5']['id']);?>" alt=""/>
				<?php endif;?>
            </div>
            <div class="blur-shape-2">
                <?php  if ( !empty(esc_url($settings['image6']['id']) )) : ?>   
					<img src="<?php echo wp_get_attachment_url($settings['image6']['id']);?>" alt=""/>
				<?php endif;?>
            </div>
             <div class="container">
                <div class="row justify-content-center">
                    <div class="col-xl-12">
                        <div class="hero-content">
                            <h6 class="wow fadeInUp"><?php echo $settings['subtitle'];?></h6>
                            <h1 class="wow fadeInUp" data-wow-delay=".3s">
                                <?php echo $settings['title'];?>
                            </h1>
                            <p class="wow fadeInUp" data-wow-delay=".5s">
                                <?php echo $settings['text'];?>
                            </p>
                            <div class="hero-button wow fadeInUp" data-wow-delay=".3s">

								<?php if($settings['button']): ?>
                                <a href="<?php echo esc_url($settings['button_link']['url']);?>" class="gt-theme-btn">
                                    <?php echo $settings['button'];?>
                                </a>
								<?php endif; ?>
								<?php if($settings['button2']): ?>
                                <a href="<?php echo esc_url($settings['button_link2']['url']);?>" class="gt-theme-btn gt-style-border">
                                    <?php echo $settings['button2'];?>
                                </a>
								<?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
             </div>
         </div>

             
		<?php 
	}


}

Plugin::instance()->widgets_manager->register_widget_type(new Banner_5());