<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Geroz
 * @since 1.0.0
 */ 
 
class Home5_Content_Write 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-content-write-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 Content Write', '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-content-write',
			[
				'label' => esc_html__( 'Writer Content', 'geroz-core' ),
			]
		);	

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

		$this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', '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(
			'title2',
			[
				'label' => esc_html__( 'Title 2', '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(
			'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(
			'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');
		?>

		<div class="content-writing bg-cover section-padding"
			style="background-image: url(<?php echo wp_get_attachment_url($settings['bg_image']['id']);?>);">
			<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>
						<?php echo $settings['button'];?>
					</p>
				</div>
			</a>
			<div class="container">
				<div class="content wow fadeInUp" data-wow-delay="400ms">
					<h2>
						<span><?php echo $settings['title'];?></span>
						<span> <?php echo $settings['title2'];?></span>
					</h2>
					<p><?php echo $settings['text'];?></p>
					<div class="icon"><i class="fal fa-long-arrow-right"></i></div>

				</div>
			</div>
		</div>
             
		<?php 
	}


}

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