<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Geroz
 * @since 1.0.0
 */ 
 
class Home3_Contact 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 'geroz-home3-contact-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__( 'Home 3 Contact', 'geroz-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 ['geroz_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(
			'home3-contact-content',
			[
				'label' => esc_html__( 'Contact Content', 'geroz-core' ),
			]
		);	

		$this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Contact Us', 'geroz-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'contact_form',
			[
				'label' => esc_html__( 'Contact Form', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => '[contact-form-7 id="123" title="Contact form 1"]',
				'label_block' => true,
			]
		);

		$this->add_control(
			'address',
			[
				'label' => esc_html__( 'Address', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( '123 Street, City, Country', 'geroz-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'contact_text',
			[
				'label' => esc_html__( 'Contact Text', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Get in touch with us', 'geroz-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'phone',
			[
				'label' => esc_html__( 'Phone', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( '+123 456 7890', 'geroz-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'email',
			[
				'label' => esc_html__( 'Email', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'info@example.com', 'geroz-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'button',
			[
				'label' => esc_html__( 'Button Text', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Get in Touch', 'geroz-core' ),
				'label_block' => true,
			]
		);

		$this->add_control(
			'button_link',
			[
				'label' => esc_html__( 'Button Link', 'geroz-core' ),
				'type' => Controls_Manager::URL,
				'default' => [
					'url' => '#',
				],
				'label_block' => true,
			]
		);
		
		$this->add_control(
			'image',
			[
				'label' => esc_html__( 'Image', 'geroz-core' ),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
			]
		);


		$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="contact-us-wrapper contact-us-1 style-2 section-padding">
			<div class="container">
				<div class="row align-items-center">
					<div class="col-xl-7 col-lg-12">
						<div class="content">
							<div class="section-title pb-5 mb-5">
								<h2 class="text-white has_text_reveal_anim"><?php echo $settings['title'];?></h2>
							</div>
							<div class="contact-right pe-5 mt-4 mt-md-0">
								
								<?php echo do_shortcode( $settings['contact_form'] );?>

							</div>
						</div>
					</div>
					<div class="col-xl-5 col-lg-12">
						<div class="contact-infu">
							<div class="image-2 tp_img_reveal">
								<?php  if ( !empty(esc_url($settings['image']['id']) )) : ?>   
									<img src="<?php echo wp_get_attachment_url($settings['image']['id']);?>" alt=""/>
								<?php endif;?>
								<p><?php echo $settings['address'];?></p>
							</div>
							<div class="infu-inner d-flex align-items-center justify-content-between">
								<div class="infu">
									<h4><?php echo $settings['contact_text'];?></h4>
									<p><?php echo $settings['phone'];?></p>
									<p><?php echo $settings['email'];?></p>
								</div>
								<a href="<?php echo esc_url($settings['button_link']['url']);?>" class="circle">
									<div class="dot"></div>
									<div class="circle-icon"><i class="far fa-long-arrow-right"></i></div>
									<div class="circle-text">
										<p class="text-white">
											<?php echo $settings['button'];?>
										</p>
									</div>
								</a>
							</div>
						</div>

					</div>
				</div>
			</div>
		</section>

             
		<?php 
	}


}

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