<?php
/**
 * NinjaForm widget class
 *
 * @package Banana_Addons
 */
use Banana_Addons\Elementor\Helper;
use Elementor\Widget_Base;
use Elementor\Icons_Manager;

if ( ! defined( 'ABSPATH' ) )
	exit; // Exit if accessed directly

class Widget_NinjaForm extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'banae_ninjaform';
	}

	/**
	 * Get widget title.
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return __( 'Ninja Forms', 'banana-addons-for-elementor' );
	}

	/**
	 * Get widget icon.
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'eicon-form-horizontal';
	}

	/**
	 * Get widget categories.
	 *
	 * @return array Widget categories.
	 */
	public function get_categories() {
		return [ 'banana-addons-category' ];
	}

	/**
	 * Get widget keywords for search
	 * 
	 * @return string[]
	 */
	public function get_keywords() {
		return [ 'form', 'contact', 'feedback', 'ninjaform', 'ninja forms' ];
	}

	/**
	 * Enqueue dependend styles
	 * 
	 * Retrieve the list of style dependencies the widget requires.
	 * 
	 * @return string[]
	 */
	public function get_style_depends() {
		return [];
	}

	/**
	 * Enqueue dependend script
	 * 
	 * Retrieve the list of style dependencies the widget requires.
	 * 
	 * @return string[]
	 */
	public function get_script_depends() {
		return [];
	}

	protected function is_dynamic_content(): bool {
		return false;
	}

	/**
	 * Register widget content controls
	 */
	protected function register_controls() {

		// Instantiate the control class
		require_once 'register-controls.php';

		// Call to the register controls method
		Banae_NinjaForm_Controls::add_register_controls( $this );

	}

	protected function render() {

		if ( ! Helper::is_ninjaforms_activated() ) {
			Helper::rising_plugin_missing_notice( __( 'Ninja Forms', 'banana-addons-for-elementor' ) );
			return;
		}

		$settings = $this->get_settings_for_display();

		if ( ! empty( $settings['ninjaforms_form_id'] ) ) {
			echo Helper::banae_do_shortcode( 'ninja_forms', [
				'id' => esc_attr( $settings['ninjaforms_form_id'] ),
			] );
		}
	}
}