<?php

namespace TotalThemeCore\Vcex\Elementor\Widgets;

use VCEX_Icon_Shortcode as Shortcode;
use TotalThemeCore\Vcex\Elementor;
use TotalThemeCore\Vcex\Elementor\Register_Controls;
use Elementor\Widget_Base;

defined( 'ABSPATH' ) || exit;

class Icon extends Widget_Base {

	public function get_name() {
		return 'vcex_icon';
	}

	public function get_title() {
		return Shortcode::get_title();
	}

	public function get_icon() {
		return 'eicon-favorite';
	}

	public function get_custom_help_url() {
		// none yet.
	}

	public function get_categories() {
		return [ Elementor::CATEGORY_ID ];
	}

	public function get_keywords() {
		return [ 'icon', 'svg' ];
	}

	public function get_script_depends() {
		return [];
	}

	public function get_style_depends() {
		return [];
	}

	protected function register_controls() {
		new Register_Controls( $this, Shortcode::get_params() );
	}

	protected function render() {
		// Backward-compat for 2.7+ when the default onclick option is not None (empty)
		$settings = $this->get_settings();
		if ( ! empty( $settings['onclick_url'] ) && isset( $settings['onclick'] ) && '' === $settings['onclick'] ) {
			$this->set_settings( 'onclick', 'custom_link' );
		}

		// Get settings and display element
		$atts = $this->get_settings_for_display();
		$atts['is_elementor_widget'] = true;
		echo Shortcode::output( $atts );
	}

}
