<?php

/**
 * Elementor Widget
 * @package Meditest
 * @since 1.0.0
 */

namespace Elementor;

if (!defined('ABSPATH')) exit; // Exit if accessed directly.

class meditest_doctor_profile_card extends Widget_Base
{

	/**
	 * Get widget name.
	 *
	 * Retrieve Elementor widget name.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name()
	{
		return 'doctor-profile-card';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title()
	{
		return esc_html__('Doctor Profile Card', 'meditest-extra');
	}

	/**
	 * Get widget icon.
	 *
	 * Retrieve Elementor widget icon.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon()
	{
		return 'fas fa-th-large';
	}

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the Elementor widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories()
	{
		return ['meditest_doctor_profile'];
	}

	/**
	 * Register Elementor 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->layout_options();
	}

	/**
	 * Layout Options
	 */
	private function layout_options()
	{


		$this->start_controls_section(
			'layout_option',
			[
				'label' => __('Layout Options', 'meditest-extra'),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);





		$this->add_control(
			'doctor_card_image',
			[
				'label' => esc_html__('Select Image', 'meditest-extra'),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
			]
		);

		$this->add_control(
			'doctor_card_name',
			[
				'label' => esc_html__('Doctor Name', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('Dr. Daisy Bins', 'meditest-extra'),
				'label_block' => true,
			]
		);

		$this->add_control(
			'doctor_card_title',
			[
				'label' => esc_html__('Doctor Title', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('Dentist surgeon', 'meditest-extra'),
				'label_block' => true,
			]
		);


		$this->add_responsive_control(
			'doctor_img_height',
			[
				'label' => esc_html__('Post Image Height', 'meditest-extra'),
				'type' => Controls_Manager::SLIDER,
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1000,
					],
				],
				'devices' => ['desktop', 'tablet', 'mobile'],
				'desktop_default' => [
					'size' => 322,
					'unit' => 'px',
				],
				'tablet_default' => [
					'size' => 322,
					'unit' => 'px',
				],
				'mobile_default' => [
					'size' => 280,
					'unit' => 'px',
				],

				'default'  => [
					'unit' => 'px',
					'size' => 322,
				],

				'selectors' => [
					'{{WRAPPER}} .doctor-profile-pic img' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);


		$this->end_controls_section();
	}

	protected function render()
	{

		$settings = $this->get_settings_for_display();

?>




		<div class="doctor-profile-card-wrap">
			<div class="doctor-profile-card-inner">
				<div class="doctor-profile-pic">
					<img src="<?php echo $settings['doctor_card_image']['url']; ?>" alt="<?php echo get_the_title($settings['doctor_card_image']['id']); ?>">
				</div>
				<div class="doctor-profile-info">
					<h4><?php echo $settings['doctor_card_name']; ?></h4>
					<span><?php echo $settings['doctor_card_title']; ?></span>
				</div>
			</div>
		</div>


<?php
	}
}

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