<?php

namespace SoftMultimediaPlayer;

defined( 'ABSPATH' ) || exit();

class Elementor {

	private static $instance = null;

	public function __construct() {
		add_action( 'elementor/preview/enqueue_scripts', [ $this, 'preview_scripts' ] );

		//register elementor widget
		add_action( 'elementor/widgets/register', [ $this, 'register_widget' ] );
	}

	public function preview_scripts() {

		Enqueue::instance()->admin_assets( null );

		wp_enqueue_script( 'smp-elementor', SOFT_MULTIMEDIA_PLAYER_ASSETS . '/js/elementor.js', [
			'jquery',
			'react',
			'react-dom',
			'wp-components',
		], SOFT_MULTIMEDIA_PLAYER_VERSION, true );

	}

	/**
	 * Register elementor player widget
	 *
	 * @return void
	 * @since 1.0.0
	 *
	 */
	public function register_widget( $widgets_manager ) {

		require SOFT_MULTIMEDIA_PLAYER_PATH . '/elementor/Elementor_Player_Widget.php';

		$widgets_manager->register( new Elementor_Player_Widget() );
	}

	public static function instance() {
		if ( null === self::$instance ) {
			self::$instance = new self;
		}

		return self::$instance;
	}
}

Elementor::instance();
