<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Feron
 * @since 1.0.0
 */ 
 
class Download_Cta 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-download-cta-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__( 'Download Cta', '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() {

		// Tab Start - 1

		$this->start_controls_section(
			'download_cta_section',
			[
				'label' => esc_html__( 'Download cta', 'feron-core' ),
			]
		);	

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

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

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

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

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

		$this->add_control(
			'subtitle',
			[
				'label'       => esc_html__( 'Subtitle', 'feron-core' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'download our app', 'feron-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'title',
			[
				'label'       => esc_html__( 'Title', 'feron-core' ),
				'type'        => Controls_Manager::TEXT,
				'default'     => esc_html__( 'Get Our App & Play Like A Pro', 'feron-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'text',
			[
				'label'       => esc_html__( 'Text', 'feron-core' ),
				'type'        => Controls_Manager::TEXTAREA,
				'default'     => esc_html__( 'A game studio crafting exciting, high-quality video games, prioritizing immersive gameplay and mechanics. Lacinia at quis risus sed vulputate odio. Accumsan lacus', 'feron-core' ),
				'label_block' => 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="gt-cta-download-app-section-4 pb-0 fix section-padding bg-cover" style="background-image: url('<?php echo wp_get_attachment_url($settings['bg_image']['id']);?>');">
            <div class="gt-x-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="container">
                <div class="gt-cta-download-app-wrapper">
                    <div class="row g-4 justify-content-between">
                        <div class="col-xl-6 col-lg-6 order-2 order-xl-1">
                            <div class="gt-cta-image">
                               <?php  if ( !empty(esc_url($settings['image2']['id']) )) : ?>   
									<img src="<?php echo wp_get_attachment_url($settings['image2']['id']);?>" alt=""/>
								<?php endif;?>
                            </div>
                        </div>
                        <div class="col-xl-5 col-lg-6 order-1 order-xl-2">
                            <div class="gt-cta-content">
                                <div class="section-title-2 mb-0">
                                    <h6 class="wow fadeInUp"><?php echo $settings['subtitle'];?></h6>
                                    <h2 class="wow fadeInUp" data-wow-delay=".3s">
                                        <?php echo $settings['title'];?>
                                    </h2>
                                </div>
                                <p class="gt-cta-text wow fadeInUp" data-wow-delay=".5s">
                                    <?php echo $settings['text'];?>
                                </p>
                                <div class="gt-app-button">
                                    <?php  if ( !empty(esc_url($settings['image3']['id']) )) : ?>   
										<img src="<?php echo wp_get_attachment_url($settings['image3']['id']);?>" alt=""/>
									<?php endif;?>
                                    <?php  if ( !empty(esc_url($settings['image4']['id']) )) : ?>   
										<img src="<?php echo wp_get_attachment_url($settings['image4']['id']);?>" alt=""/>
									<?php endif;?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
             
		<?php 
	}


}

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