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

if ( ! class_exists( 'Draly_Dropshipping_Starter_Pluggable_Elementor' ) ) {
	class Draly_Dropshipping_Starter_Pluggable_Elementor {

		protected static $prefix = 'Draly_';
		protected static $initialized = false;

		public static function initialize() {
			// Do nothing if pluggable functions already initialized.
			if ( self::$initialized ) {
				return;
			}
			add_action( 'elementor/elements/categories_registered', array( __CLASS__, 'draly_dropshipping_starter_categories_registered' ) );
			add_action( 'elementor/widgets/register', array( __CLASS__, 'draly_dropshipping_starter_register_widgets' ) );
			add_action( 'elementor/frontend/after_register_styles', array(
				__CLASS__,
				'draly_dropshipping_starter_after_register_styles'
			), 20 );
			// State that initialization completed.
			self::$initialized = true;
		}

		public static function draly_dropshipping_starter_register_widgets() {
			\Elementor\Plugin::instance()->widgets_manager->register( new Draly_Dropshipping_Starter_Elementor_Blog() );;
			\Elementor\Plugin::instance()->widgets_manager->register( new Draly_Dropshipping_Starter_Elementor_Countdowndeal() );
			\Elementor\Plugin::instance()->widgets_manager->register( new Draly_Dropshipping_Starter_Elementor_Newsletter() );
			\Elementor\Plugin::instance()->widgets_manager->register( new Draly_Dropshipping_Starter_Elementor_Slider() );
			\Elementor\Plugin::instance()->widgets_manager->register( new Draly_Dropshipping_Starter_Elementor_Verticalaccordion() );
			if ( class_exists( 'WooCommerce' ) ) {
				\Elementor\Plugin::instance()->widgets_manager->register( new Draly_Dropshipping_Starter_Elementor_Category() );
				\Elementor\Plugin::instance()->widgets_manager->register( new Draly_Dropshipping_Starter_Elementor_Products() );
				\Elementor\Plugin::instance()->widgets_manager->register( new Draly_Dropshipping_Starter_Elementor_Producttabs() );
			}
		}

		public static function draly_dropshipping_starter_categories_registered( $elements_manager ) {
			$elements_manager->add_category(
				'draly-dropshipping-starter',
				[
					'title' => esc_html__( 'Draly', 'draly-dropshipping-starter' ),
				]
			);
		}

		public static function draly_dropshipping_starter_after_register_styles() {
			wp_deregister_style( 'font-awesome' );
		}
	}
}