<?php

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

namespace Elementor;

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

class meditest_custom_search_form 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 'custom-search-form';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title()
	{
		return esc_html__('Meditest Search Form', '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_widgets'];
	}

	/**
	 * 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(
			'placehoder_text',
			[
				'label' => esc_html__('Placeholder Text', 'meditest-extra'),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__('Write your search...', 'meditest-extra'),
				'label_block' => true,
			]
		);




		$this->end_controls_section();
	}

	protected function render()
	{

		$settings = $this->get_settings_for_display();

?>



		<div class="custom-search-form-wrap">
			<div class="custom-sf-inner">
				<form role="search" method="get" id="searchform" action="<?php echo home_url('/'); ?>">
					<div class="mt_mod_search_form">
						<input type="text" value="" name="s" id="s" class="form-ctn-style" placeholder="<?php echo $settings['placehoder_text']; ?>" />
						<input type="hidden" name="post_type" value="doctorsprofile services" />
						<input type="submit" id="searchsubmit" class="mtmodsf-btn" value="Find" />
					</div>
				</form>

			</div>
		</div>


<?php
	}
}

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