<?php
defined( 'ABSPATH' ) || exit;

/**
 * Elementor integration bootstrap.
 */
class AWP_Elementor {

	/**
	 * @var AWP_Elementor|null
	 */
	private static $instance = null;

	/**
	 * @return AWP_Elementor
	 */
	public static function get_instance() {
		if ( null === self::$instance ) {
			self::$instance = new self();
		}
		return self::$instance;
	}

	/**
	 * Hooks. Safe if Elementor is inactive (actions never fire).
	 */
	public function init() {
		add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) );
		add_action( 'elementor/elements/categories_registered', array( $this, 'register_category' ) );
	}

	/**
	 * Register widget category.
	 *
	 * @param \Elementor\Elements_Manager $elements_manager Manager.
	 */
	public function register_category( $elements_manager ) {
		$elements_manager->add_category(
			'awp-slider',
			array(
				'title' => __( 'AWP Slider', 'advance-wp-slider' ),
				'icon'  => 'fa fa-plug',
			)
		);
	}

	/**
	 * Register widgets.
	 *
	 * @param \Elementor\Widgets_Manager $widgets_manager Manager.
	 */
	public function register_widgets( $widgets_manager ) {
		require_once AWP_PLUGIN_PATH . 'elementor/widgets/class-awp-slider-widget.php';
		$widgets_manager->register( new AWP_Slider_Widget() );
	}
}
