<?php

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

namespace Elementor;

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

class meditest_doctor_personal_info 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-personal-info';
	}

	/**
	 * 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 Personal Inof', '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(
			'info_seciton_title',
			[
				'label' => esc_html__('Info Section Title', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('Personal Info', 'meditest-extra'),
				'label_block' => true,
			]
		);

		$this->add_control(
			'info_address',
			[
				'label' => esc_html__('Address', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('Dhaka mirpur, Eidson, 3731', 'meditest-extra'),
				'label_block' => true,
			]
		);
		$this->add_control(
			'info_email',
			[
				'label' => esc_html__('Email', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('your-email@gmail.com', 'meditest-extra'),
				'label_block' => true,
			]
		);
		$this->add_control(
			'info_phone',
			[
				'label' => esc_html__('Phone', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('+000-010-000-050', 'meditest-extra'),
				'label_block' => true,
			]
		);
		$this->add_control(
			'info_website',
			[
				'label' => esc_html__('Website', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('https://example.com', 'meditest-extra'),
				'label_block' => true,
			]
		);


		$repeater = new Repeater();

		$repeater->add_control(
			'social_title',
			[
				'label' => esc_html__('Title', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('Best Service', 'meditest-extra'),
				'label_block' => true,
			]
		);

		$repeater->add_control(
			'social_icon',
			[
				'label' => esc_html__('Social Icon', 'textdomain'),
				'type' => Controls_Manager::ICONS,
				'default' => [
					'value' => 'fab fa-facebook-f',
					'library' => 'fa-solid',
				],
			]
		);

		$repeater->add_control(
			'social_link',
			[
				'label' => esc_html__('Social Profile Link', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('https://www.facebook.com/codeindeed', 'meditest-extra'),
				'label_block' => true,
			]
		);


		$this->add_control(
			'social_lists',
			[
				'label' => esc_html__('Slider Image List', 'meditest-extra'),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'default' => [
					[
						'social_title' => esc_html__('Faebook', 'meditest-extra'),
					],
				],
				'title_field' => '{{{ social_title }}}',
			]
		);




		$this->end_controls_section();
	}

	protected function render()
	{

		$settings = $this->get_settings_for_display();

		$social_lists = $settings['social_lists'];

?>




		<div class="doctor-personal-info-wrap">
			<div class="doctor-personal-info-inner">
				<h4 class="personal-ist"><?php echo $settings['info_seciton_title']; ?></h4>

				<ul class="dpi-list">
					<li>
						<span class="dpi-label"><?php echo esc_html('Address: ', 'meditest-extra'); ?></span>
						<span class="dpi-data"><?php echo $settings['info_address']; ?></span>
					</li>
					<li>
						<span class="dpi-label"><?php echo esc_html('Email: ', 'meditest-extra'); ?></span>
						<span class="dpi-data"><?php echo $settings['info_email']; ?></span>
					</li>
					<li>
						<span class="dpi-label"><?php echo esc_html('Phone: ', 'meditest-extra'); ?></span>
						<span class="dpi-data"><?php echo $settings['info_phone']; ?></span>
					</li>
					<li>
						<span class="dpi-label"><?php echo esc_html('Website: ', 'meditest-extra'); ?></span>
						<span class="dpi-data"><?php echo $settings['info_website']; ?></span>
					</li>
				</ul>

				<div class="dpi-social-profiles">
					<span><?php echo esc_html('Follow me: '); ?></span>
					<div class="dpi-social_lists">
						<?php if (!empty($social_lists)) {
							foreach ($social_lists as $social_list) {
						?>
								<a href="<?php echo esc_url($social_list['social_link']); ?>"><?php Icons_Manager::render_icon($social_list['social_icon'], ['aria-hidden' => 'true']); ?></a>
						<?php }
						} ?>
					</div>
				</div>
			</div>

		</div>


<?php
	}
}

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