<?php

namespace TRANZIXPLUGIN\Element;


class Elementor {
	static $widgets = array(
		'slider',
		'feature',
		'about_left',
		'about_right',
		'service',
		'video',
		'chooseus_left',
		'chooseus_right',
		'process',
		'skills_left',
		'skills_right',
		'clients',
		'testimonials',
		'funfact',
		'pricing_tab',
		'cta',
		'blog',
		'footer',
		'about',
		'team',
		'graph_left',
		'graph_right',
		'gallery',
		'subscribe',
		'graph',
		'portfolios',
		'contact',
		'quote_left',
		'quote_right',
		'slider',
		'support_left',
		'support_right',
		'chooseus',
		'service_tab',
		'skills',
		'domain',
		'faq_left',
		'faq_right',
		'process_left',
		'process_right',
		'download_left',
		'download_right',
		'request',
		'service_tab2',
		'service_tab3',
		'title',
		'mission',
		'service_tab4',
		'faq',
		'service_details',
		'service_details2',
		'service_details3',
		'wi_catagory',
		'wi_contact',
		'wi_info',
		'wi_testimonials',
		'wi_download',
		'career',
		'job_category',
		'positions',
		'team_details',
		'team_details2',
		'team_details3',
		'team_details4',
		'team_details5',
		'coming_soon',
		'pricing',
		'contactinfo',
		'project_details',
		'project_details1',
		'project_details2',
		'h1_slider',
		'h1_about_left',
		'h1_about_right',
		'h1_service',
		'h1_gallery_tab',
		'h1_skill',
		'h1_team',
		'h1_video',
		'h1_funfact',
		'h1_testimonials',
		'h1_subscribe',
		'h1_blog',
		'our_clients',
	);

	static function init() {
		add_action( 'elementor/init', array( __CLASS__, 'loader' ) );
		add_action( 'elementor/elements/categories_registered', array( __CLASS__, 'register_cats' ) );
	}

	static function loader() {

		foreach ( self::$widgets as $widget ) {

			$file = TRANZIXPLUGIN_PLUGIN_PATH . '/elementor/' . $widget . '.php';
			if ( file_exists( $file ) ) {
				require_once $file;
			}

			add_action( 'elementor/widgets/widgets_registered', array( __CLASS__, 'register' ) );
		}
	}

	static function register( $elemntor ) {
		foreach ( self::$widgets as $widget ) {
			$class = '\\TRANZIXPLUGIN\\Element\\' . ucwords( $widget );

			if ( class_exists( $class ) ) {
				$elemntor->register_widget_type( new $class );
			}
		}
	}

	static function register_cats( $elements_manager ) {

		$elements_manager->add_category(
			'tranzix',
			[
				'title' => esc_html__( 'Tranzix', 'tranzix' ),
				'icon'  => 'fa fa-plug',
			]
		);
		$elements_manager->add_category(
			'csslatepath',
			[
				'title' => esc_html__( 'Template Path', 'tranzix' ),
				'icon'  => 'fa fa-plug',
			]
		);

	}
}

Elementor::init();