<?php

class DCBP_Main {
	
	protected $plugin_name;
	protected $version;
	protected $loader;

	public function __construct() {
		if ( defined( 'DCBP_PLUGIN_VERSION' ) ) {
			$this->version = DCBP_PLUGIN_VERSION;
		} else {
			$this->version = '1.0.0';
		}
		$this->plugin_name = 'dartamas';
		
		$this->load_dependencies();
		$this->set_variable();
		$this->set_locale();
		$this->define_admin_hooks();		
		$this->define_public_hooks();
		

	}
	function set_selected_pages() {
		global $dt_hselected_pages; 
		$dt_hselected_pages = 'DCBP';   
	}
	
	private function set_variable(){
		$this->loader->add_action( 'after_setup_theme',$this, 'set_selected_pages' );
	}
	private function load_dependencies() {						
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-DCBP-loader.php';
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-DCBP-i18n.php';
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-DCBP-admin.php';
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-DCBP-public.php';		
		$this->loader = new DCBP_Loader();
	}
	private function set_locale() {
		$plugin_i18n = new DCBP_i18n();
		$this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' );
		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
	}	

	private function define_admin_hooks() {
		$plugin_admin = new DCBP_Admin( $this->get_plugin_name(), $this->get_version() );
		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );

		
		$this->loader->add_action('carbon_fields_register_fields', $plugin_admin, 'setup_settings_ui');	
		$this->loader->add_action('carbon_fields_theme_options_container_saved', $plugin_admin, 'settings_ui_save');
		

        $this->loader->add_action('after_setup_theme', $plugin_admin, 'crb_load');
		
    }
	private function define_public_hooks() {
		$plugin_public = new DCBP_Public( $this->get_plugin_name(), $this->get_version() );		
		$this->loader->add_action( 'woocommerce_single_product_summary', $plugin_public,'enqueue_scripts_item' );
		$this->loader->add_action( 'wp_footer', $plugin_public,'enqueue_scripts' );
	}
	
	public function run() {
		$this->loader->run();
	}
	
	public function get_plugin_name() {
		return $this->plugin_name;
	}

	public function get_version() {
		return $this->version;
	}

}
