<?php

if (!defined('ABSPATH')) exit;

require_once ('controls/icons.php');

class Themedraft_Elementor_Config {

	public function __construct() {
		add_action( 'elementor/frontend/after_register_scripts', array( $this, 'themedraft_core_register_scripts' ) );
	}

	public function themedraft_core_register_scripts() {
		$td_map_api_key = induxter_option( 'google_map_api_key' );
		if ( $td_map_api_key ) {
			wp_register_script( 'google-maps-script', 'https://maps.googleapis.com/maps/api/js?key=' . $td_map_api_key . '', array(), '1.0', false );
			wp_register_script( 'google-map-js', plugins_url( '/', __FILE__ ) . 'assets/js/gmap.js', array( 'jquery' ), '1.0', true );
		}
		wp_register_script( 'counterup', plugins_url( '/', __FILE__ ) . 'assets/js/counterup.js', array( 'jquery' ), '1.0', true );
		wp_register_script( 'appear', plugins_url( '/', __FILE__ ) . 'assets/js/appear.js', array( 'jquery' ), '1.0', false );
		wp_register_script('event-move', plugins_url('/', __FILE__) . 'assets/js/jquery.event.move.js', array('jquery'), 1.0, true);
		wp_register_script('twentytwenty', plugins_url('/', __FILE__) . 'assets/js/jquery.twentytwenty.js', array('jquery','event-move'), 1.0, true);
	}
}

new Themedraft_Elementor_Config();

class Themedraft_Elementor_Widget {

	private static $instance = null;

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

		return self::$instance;
	}

	public function themedraft_add_elementor_widgets() {

		// Check if the Elementor plugin has been installed / activated.
		if ( defined( 'ELEMENTOR_PATH' ) && class_exists( 'Elementor\Widget_Base' ) && function_exists('induxter_option') ) {

			$accordion_widget = induxter_option('accordion_widget', true);
			if($accordion_widget == true){
				require_once( 'accordion-widget.php' );
			}

			$award_image_slider_widget = induxter_option('award_image_slider_widget', true);
			if($award_image_slider_widget == true){
				require_once( 'award-image-slider-widget.php' );
			}

			require_once('brand-imag-slider-widget.php');

			$button_widget = induxter_option('button_widget', true);
			if($button_widget == true){
				require_once( 'button-widget.php' );
			}

			require_once('contact-and-subscribe-widget.php');

			$contact_form_7_widget = induxter_option('contact_form_7_widget', true);
			if($contact_form_7_widget == true){
				require_once( 'contact-form7-widget.php' );
			}

			$contact_info_widget = induxter_option('contact_info_widget', true);
			if($contact_info_widget == true){
				require_once( 'contact-info-widget.php' );
			}

			$countup_widget = induxter_option('countup_widget', true);
			if($countup_widget == true){
				require_once( 'counter-up-widget.php' );
			}

			$countup_two_widget = induxter_option('countup_two_widget', true);
			if($countup_two_widget == true){
				require_once( 'counter-up-two-widget.php' );
			}

			$call_to_action_widget = induxter_option('call_to_action_widget', true);
			if($call_to_action_widget == true){
				require_once( 'cta-widget.php' );
			}

			$filterable_gallery_widget = induxter_option('filterable_gallery_widget', true);
			if($filterable_gallery_widget == true){
				require_once( 'filterable-gallery-widget.php' );
			}

			$google_map_widget = induxter_option('google_map_widget', true);
			if($google_map_widget == true){
				require_once( 'google-map-widget.php' );
			}

			$home_one_slider_widget = induxter_option('home_one_slider_widget', true);
			if($home_one_slider_widget == true){
				require_once( 'home-one-slider-widget.php' );
			}

			$home_two_slider_widget = induxter_option('home_two_slider_widget', true);
			if($home_two_slider_widget == true){
				require_once( 'home-two-slider-widget.php' );
			}

			$home_three_slider_widget = induxter_option('home_three_slider_widget', true);
			if($home_three_slider_widget == true){
				require_once( 'home-three-slider-widget.php' );
			}

			require_once( 'home-four-slider-widget.php' );

			require_once( 'image-compare-widget.php' );

			$image_widget = induxter_option('image_widget', true);
			if($image_widget == true){
				require_once( 'image-widget.php' );
			}

			$pricing_table_widget = induxter_option('pricing_table_widget', true);
			if($pricing_table_widget == true){
				require_once( 'pricing-table-widget.php' );
			}

			$project_info_slider_widget = induxter_option('project_info_slider_widget', true);
			if($project_info_slider_widget == true){
				require_once( 'project-details-slider.php' );
			}

			$project_slider_widget = induxter_option('project_slider_widget', true);
			if($project_slider_widget == true){
				require_once( 'projects-slider-widget.php' );
			}

			$project_slider_three_widget = induxter_option('project_slider_three_widget', true);
			if($project_slider_three_widget == true){
				require_once( 'project-slider-three-widget.php' );
			}

			$project_dynamic_widget = induxter_option('project_dynamic_widget', true);
			if($project_dynamic_widget == true){
				require_once( 'projects-dynamic-widget.php' );
			}

			$projects_section_widget = induxter_option('projects_section_widget', true);
			if($projects_section_widget == true){
				require_once( 'projects-section-widget.php' );
			}

			$promo_box_widget = induxter_option('promo_box_widget', true);
			if($promo_box_widget == true){
				require_once( 'promo-box-widget.php' );
			}

			$promo_box_two_widget = induxter_option('promo_box_two_widget', true);
			if($promo_box_two_widget == true){
				require_once( 'promo-box-two-widget.php' );
			}

			$recent_posts_widget = induxter_option('recent_posts_widget', true);
			if($recent_posts_widget == true){
				require_once( 'recent-post-widget.php' );
			}

			$section_title_widget = induxter_option('section_title_widget', true);
			if($section_title_widget == true){
				require_once( 'section-title-widget.php' );
			}

			$section_title_two_widget = induxter_option('section_title_two_widget', true);
			if($section_title_two_widget == true){
				require_once( 'section-title-two.php' );
			}

			$service_box_one_widget = induxter_option('service_box_one_widget', true);
			if($service_box_one_widget == true){
				require_once( 'service-box-one-widget.php' );
			}

			$service_box_two_widget = induxter_option('service_box_two_widget', true);
			if($service_box_two_widget == true){
				require_once( 'service-box-two-widget.php' );
			}

			$service_box_three_widget = induxter_option('service_box_three_widget', true);
			if($service_box_three_widget == true){
				require_once( 'service-box-three-widget.php' );
			}

			require_once( 'service-box-four-widget.php' );

			$skill_bar_line_widget = induxter_option('skill_bar_line_widget', true);
			if($skill_bar_line_widget == true){
				require_once( 'skill-bar-line-widget.php' );
			}

			$tabs_widget = induxter_option('tabs_widget', true);
			if($tabs_widget == true){
				require_once( 'tabs-widget.php' );
			}

			$team_member_one_widget = induxter_option('team_member_one_widget', true);
			if($team_member_one_widget == true){
				require_once( 'team-member-one.php' );
			}

			$team_member_two_widget = induxter_option('team_member_two_widget', true);
			if($team_member_two_widget == true){
				require_once( 'team-member-two-widget.php' );
			}

			$team_member_three_widget = induxter_option('team_member_three_widget', true);
			if($team_member_three_widget == true){
				require_once( 'team-member-three-widget.php' );
			}

			require_once( 'team-member-four-widget.php' );

			$team_member_minimal_widget = induxter_option('team_member_minimal_widget', true);
			if($team_member_minimal_widget == true){
				require_once( 'team-member-minimal-widget.php' );
			}

			$team_member_info_widget = induxter_option('team_member_info_widget', true);
			if($team_member_info_widget == true){
				require_once( 'team-member-info-widget.php' );
			}

			$testimonial_one_widget = induxter_option('testimonial_one_widget', true);
			if($testimonial_one_widget == true){
				require_once( 'testimonial-widget.php' );
			}

			$testimonial_two_widget = induxter_option('testimonial_two_widget', true);
			if($testimonial_two_widget == true){
				require_once( 'testimonial-two-widget.php' );
			}

			$testimonial_three_widget = induxter_option('testimonial_three_widget', true);
			if($testimonial_three_widget == true){
				require_once( 'testimonial-three-widget.php' );
			}

			require_once( 'testimonial-four-widget.php' );

			$title_with_text_widget = induxter_option('title_with_text_widget', true);
			if($title_with_text_widget == true){
				require_once( 'text-with-title-widget.php' );
			}

			$video_popup_widget = induxter_option('video_popup_widget', true);
			if($video_popup_widget == true){
				require_once( 'video-popup-widget.php' );
			}
		}
	}

	public function init() {
		add_action('elementor/widgets/register', array($this, 'themedraft_add_elementor_widgets'));
	}
}

Themedraft_Elementor_Widget::get_instance()->init();


// Add New Category In Elementor Widget

function themedraft_elementor_widget_categories( $elements_manager ) {

	$elements_manager->add_category(
		'themedraft_elements',
		[
			'title' => __( 'Themedraft Elements', 'themedraft-core' ),
		]
	);

}

add_action('elementor/elements/categories_registered', 'themedraft_elementor_widget_categories');