<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

require_once __DIR__ . '/widget-controls.php';
require_once __DIR__ . '/widget-content-template.php';
require_once __DIR__ . '/widget-render.php';

class ElementSell_Widget extends \Elementor\Widget_Base {

    use ElementSell_Widget_Controls;
    use ElementSell_Widget_Render;
    use ElementSell_Widget_Content_Template;

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

    public function get_title() {
        return __( 'Formulář ElementSell', 'platebni-formular' );
    }

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

    public function get_categories() {
        return [ 'basic' ];
    }

    protected function register_controls() {
        $this->register_widget_controls();
    }

    public function get_settings_for_display( $setting_key = null ) {
        $settings = parent::get_settings_for_display();

        if ( function_exists( 'elementsell_merge_payment_widget_global_defaults' ) ) {
            $settings = elementsell_merge_payment_widget_global_defaults( $settings );
        }

        return null !== $setting_key ? ( $settings[ $setting_key ] ?? null ) : $settings;
    }

    protected function render() {
        $this->render_form();
    }

    protected function content_template() {
        $this->render_form_content_template();
    }
}