<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Geroz
 * @since 1.0.0
 */ 
 
class Home5_Aboutme 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-home5-aboutme-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 5 About Me', '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(
			'home5-aboutme-content',
			[
				'label' => esc_html__( 'About Me Content', 'geroz-core' ),
			]
		);	

		$this->add_control(
			'subtitle',
			[
				'label' => esc_html__( 'Subtitle', 'geroz-core' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'About Me', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your subtitle here', 'geroz-core' ),
			]
		);

		$this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'I love crafting beautiful, smart & inspired work that is focused on a business and creating successful digital services', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your title here', 'geroz-core' ),
			]
		);

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

		$this->add_control(
			'text',
			[
				'label' => esc_html__( 'Text', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Strategy, design and implementation as an effective complete solution. Your authentic website as a digital customer magnet.', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your text here', 'geroz-core' ),
			]
		);

		
		$this->add_control(
			'long_text',
			[
				'label' => esc_html__( 'Text', 'geroz-core' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Our team of experienced attorneys has a diverse range of expertise, covering a wide
                                    spectrum of legal areas. We specialize in corporate law, family law. Legal advocacy
                                    for diverse and the of Conducting in-depth think. Our team of experienced attorneys
                                    has a diverse range of expertise.', 'geroz-core' ),
				'placeholder' => esc_html__( 'Type your text here', 'geroz-core' ),
			]
		);


		$this->add_control(
			'button',
			[
				'label'       => __( 'Button', 'geroz-core' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => [
					'active' => true,
				],
				'placeholder' => esc_html__( 'Enter your button text', 'geroz-core' ),
				'default' => esc_html__('Hire Me For Your
                                    Projects', 'geroz-core'),
			]
		);	

		$this->add_control(
			'button_link',
			[
			  'label' => __( 'Button Url', 'geroz-core' ),
			  'type' => Controls_Manager::URL,
			  'placeholder' => __( 'https://your-link.com', 'geroz-core' ),
			  'show_external' => true,
			  'default' => [
				'url' => '#',
				'is_external' => true,
				'nofollow' => 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="about-wrapper about-1 style-3 section-padding ">
			<div class="container">
				<div class="row">
					<div class="col-xl-4 col-lg-4">
						<div class="section-title">
							<div class="sub-title">
								<div class="dot"></div> <span><?php echo $settings['subtitle'];?></span>
							</div>
						</div>
					</div>
					<div class="col-xl-12">
						<div class="section-title text-splite-up">
							<h2><?php echo $settings['title'];?></h2>
						</div>
					</div>
				</div>
				<div class="row mt-lg-5 pt-5 g-5">
					<div class="col-xl-6 col-lg-4 col-md-3">
						<div class="shape text-center">
							<?php  if ( !empty(esc_url($settings['image']['id']) )) : ?>   
								<img src="<?php echo wp_get_attachment_url($settings['image']['id']);?>" alt=""/>
							<?php endif;?>
						</div>
					</div>
					<div class="col-xl-6 col-lg-8 col-md-9">
						<div class="about-content mx-4">
							<h4 class="has_text_reveal_anim"><?php echo $settings['text'];?></h4>
							<p class="mt-4 has_fade_anim">
								<?php echo $settings['long_text'];?>
							</p>
							<a href="<?php echo esc_url($settings['button_link']['url']);?>" class="theme-btn trasparent-btn-2 mt-5 has_fade_anim"><?php echo $settings['button'];?></a>
						</div>
					</div>
				</div>
			</div>
		</section>

             
		<?php 
	}


}

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