<?php
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

/**
 * Elementor oEmbed Widget.
 *
 * Elementor widget that inserts an embbedable content into the page, from any given URL.
 *
 * @since 1.0.0
 */
class Elementor_logo_Widget extends \Elementor\Widget_Base {

/**
 * Get widget name.
 *
 * Retrieve oEmbed widget name.
 *
 * @return string Widget name.
 * @since 1.0.0
 * @access public
 */
public function get_name()
{
    return 'hyperkala_logo_Widget';
}

/**
 * Get widget title.
 *
 * Retrieve oEmbed widget title.
 *
 * @return string Widget title.
 * @since 1.0.0
 * @access public
 */
public function get_title()
{
    return 'لوگو سایت';
}

/**
 * Get widget icon.
 *
 * Retrieve oEmbed widget icon.
 *
 * @return string Widget icon.
 * @since 1.0.0
 * @access public
 */
public function get_icon()
{
    return 'eicon-logo';
}

/**
 * Get custom help URL.
 *
 * Retrieve a URL where the user can get more information about the widget.
 *
 * @return string Widget help URL.
 * @since 1.0.0
 * @access public
 */
public function get_custom_help_url()
{
    return 'https://developers.elementor.com/docs/widgets/';
}

/**
 * Get widget categories.
 *
 * Retrieve the list of categories the oEmbed widget belongs to.
 *
 * @return array Widget categories.
 * @since 1.0.0
 * @access public
 */
public function get_categories()
{
    return ['basic-hyperkala'];
}

/**
 * Get widget keywords.
 *
 * Retrieve the list of keywords the oEmbed widget belongs to.
 *
 * @return array Widget keywords.
 * @since 1.0.0
 * @access public
 */
public function get_keywords()
{
    return ['oembed', 'url', 'link'];
}

/**
 * Register oEmbed widget controls.
 *
 * Add input fields to allow the user to customize the widget settings.
 *
 * @since 1.0.0
 * @access protected
 */

protected function register_controls()
{

    $this->start_controls_section(
        'content_section',
        [
            'label' => 'تنظیمات محتوا',
            'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
    );
    $this->add_control(
        'image',
        [
            'label' => 'انتخاب تصویر',
            'type' => \Elementor\Controls_Manager::MEDIA,
            'default' => [
                'url' => \Elementor\Utils::get_placeholder_image_src(),
            ],
        ]
    );
    $this->add_control(
        'image_link',
        [
            'label' => 'لینک تصویر',
            'type' => \Elementor\Controls_Manager::TEXT,
        ]
    );
    $this->end_controls_section();
}

/**
 * Render oEmbed 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();
?>
    <a href="<?php echo $settings['image_link'];?>"></a><img src="<?php echo $settings['image']['url'];?>" alt="" class="logo-element">
    <?php
}

}
