<?php
/**
 * GoodMeet Elementor Integrator
 * Integrates goodmeet widgets with Elementor.
 *
 * @package goodmeet
 */

namespace SOVLIX\GOODMEET\Elementor;

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

use Elementor\Elements_Manager;

if ( ! class_exists( 'Goodmeet_Elementor_Integrator' ) ) {
	/**
	 * Class Goodmeet_Elementor_Integrator
	 * Integrates goodmeet widgets with Elementor.
	 */
	class Goodmeet_Elementor_Integrator {
		/**
		 * Class constructor.
		 *
		 * Hooks into the 'plugins_loaded' action to initiate the plugin.
		 */
		public function __construct() {
			add_action( 'elementor/elements/categories_registered', array( $this, 'add_elementor_widget_categories' ), 10 );
			add_action( 'elementor/widgets/register', array( $this, 'register_oembed_widget' ) );
		}

		/**
		 * Add custom category for goodmeet widgets.
		 *
		 * @param \Elementor\Elements_Manager $elements_manager Elementor elements manager.
		 * @return void
		 */
		public function add_elementor_widget_categories( $elements_manager ) {
			$elements_manager->add_category(
				'goodmeet-category',
				array(
					'title' => __( 'goodmeet Widgets', 'goodmeet' ),
					'icon'  => 'fa fa-plug',
				)
			);
		}

		/**
		 * Register oEmbed Widget.
		 *
		 * Include widget file and register widget class.
		 *
		 * @since 1.0.0
		 * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
		 * @return void
		 */
		public function register_oembed_widget( $widgets_manager ) {
			$widgets_manager->register( new Widgets\Goodmeet_Google_Meet_Elementor() );
		}
	}
}
