<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Pubzi
 * @since 1.0.0
 */ 
 
class Banner_2 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 'pubzi-banner-2-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 2', 'pubzi-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 ['pubzi_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() {


		// Tab Start - 1

		$this->start_controls_section(
			'banner_images',
			[
				'label' => esc_html__( 'Banner Images', 'pubzi-core' ),
			]
		);	

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

		$this->add_control(
			'image',
				[
					'label' => __( 'Image', 'pubzi-core' ),
					'type' => Controls_Manager::MEDIA,
					'default' => ['url' => Utils::get_placeholder_image_src(),],
				]
		);	

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

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

		$this->add_control(
			'image4',
				[
					'label' => __( 'Image 4', 'pubzi-core' ),
					'type' => Controls_Manager::MEDIA,
					'default' => ['url' => Utils::get_placeholder_image_src(),],
				]
		);	
		
		$this->add_control(
			'image5',
				[
					'label' => __( 'Image 5', 'pubzi-core' ),
					'type' => Controls_Manager::MEDIA,
					'default' => ['url' => Utils::get_placeholder_image_src(),],
				]
		);

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

		$this->add_control(
			'image7',
				[
					'label' => __( 'Image 7', 'pubzi-core' ),
					'type' => Controls_Manager::MEDIA,
					'default' => ['url' => Utils::get_placeholder_image_src(),],
				]
		);

		$this->add_control(
			'image8',
				[
					'label' => __( 'Image 8', 'pubzi-core' ),
					'type' => Controls_Manager::MEDIA,
					'default' => ['url' => Utils::get_placeholder_image_src(),],
				]
		);

		$this->add_control(
			'image9',
				[
					'label' => __( 'Image 9', 'pubzi-core' ),
					'type' => Controls_Manager::MEDIA,
					'default' => ['url' => Utils::get_placeholder_image_src(),],
				]
		);

		$this->add_control(
			'image10',
				[
					'label' => __( 'Image 10', 'pubzi-core' ),
					'type' => Controls_Manager::MEDIA,
					'default' => ['url' => Utils::get_placeholder_image_src(),],
				]
		);

		$this->add_control(
			'image11',
				[
					'label' => __( 'Image 11', 'pubzi-core' ),
					'type' => Controls_Manager::MEDIA,
					'default' => ['url' => Utils::get_placeholder_image_src(),],
				]
		);


		$this->end_controls_section();

		// Tab Start - 2

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

		$this->add_control(
			'subtitle',
			[
				'label'       => __( 'Sub Title', 'pubzi-core' ),
				'type'        => Controls_Manager::TEXTAREA,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter your sub-title', 'pubzi-core' ),
			]
		);	

		
		$this->add_control(
			'title',
			[
				'label'       => __( 'Title', 'pubzi-core' ),
				'type'        => Controls_Manager::TEXTAREA,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter your title', 'pubzi-core' ),
			]
		);

		$this->add_control(
			'text',
			[
				'label'       => __( 'Description Text', 'pubzi-core' ),
				'type'        => Controls_Manager::TEXTAREA,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => __( 'Enter Your Text', 'pubzi-core' ),
			]
		);	


		$this->add_control(
			'button',
			[
				'label'       => __( 'Button', 'pubzi-core' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => esc_html__( 'Enter your button text', 'pubzi-core' ),
				'default' => esc_html__('Read More', 'pubzi-core'),
			]
		);

		$this->add_control(
			'button_link',
			[
			  'label' => __( 'Button Url', 'pubzi-core' ),
			  'type' => Controls_Manager::URL,
			  'placeholder' => __( 'https://your-link.com', 'pubzi-core' ),
			  'show_external' => true,
			  'default' => [
				'url' => '',
				'is_external' => true,
				'nofollow' => true,
			  ],
			
		   ]
		);			

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

		<section class="hero-section hero-2 bg-cover" style="background-image: url('<?php echo wp_get_attachment_url($settings['bg_image']['id']);?>');">
            <div class="top-shape">
			<?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="top-line">
            <?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="bottom-shape">
            <?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="left-shape float-bob-y">
            <?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="right-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="right-shape2 float-bob-y">
            <?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="game-controll float-bob-x">
            <?php  if ( !empty(esc_url($settings['image7']['id']) )) : ?>   
				<img src="<?php echo wp_get_attachment_url($settings['image7']['id']);?>" alt=""/>
			<?php endif;?>
            </div>
            <div class="game-controll-bg">
            <?php  if ( !empty(esc_url($settings['image8']['id']) )) : ?>   
				<img src="<?php echo wp_get_attachment_url($settings['image8']['id']);?>" alt=""/>
			<?php endif;?>
            </div>
             <div class="right-shape-3">
            <?php  if ( !empty(esc_url($settings['image9']['id']) )) : ?>   
				<img src="<?php echo wp_get_attachment_url($settings['image9']['id']);?>" alt=""/>
			<?php endif;?>
            </div>
            <div class="blur-shape">
            <?php  if ( !empty(esc_url($settings['image10']['id']) )) : ?>   
				<img src="<?php echo wp_get_attachment_url($settings['image10']['id']);?>" alt=""/>
			<?php endif;?>
            </div>
            <div class="container">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="hero-content">
                            <span class="sub-title wow fadeInUp"><?php echo $settings['subtitle'];?></span>
                            <h1 class="wow fadeInUp" data-wow-delay=".3s">
                                <?php echo $settings['title'];?>
                            </h1>
                            <div class="hero-sub-content">
                                <p class="wow fadeInUp" data-wow-delay=".5s">
                                   <?php echo $settings['text'];?>
                                </p>
                                <a href="<?php echo esc_url($settings['button_link']['url']);?>" class="theme-btn style-2 wow fadeInUp" data-wow-delay=".7s">
                                    <span class="left-line"></span>
                                    <?php echo $settings['button'];?>
                                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
                                    <path d="M9.41099 8.46917L1.88219 16L0 14.1166L7.53013 6.58846L0.941096 0H16V15.0576L9.41099 8.46917Z" fill="#0B0E13"/>
                                    </svg>
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
             <div class="hero-image wow bounceInRight" data-wow-delay="700ms" data-wow-duration="1000ms">
            <?php  if ( !empty(esc_url($settings['image11']['id']) )) : ?>   
				<img src="<?php echo wp_get_attachment_url($settings['image11']['id']);?>" alt=""/>
			<?php endif;?>
            </div>
        </section>

             
		<?php 
	}


}

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