<?php
/*
 * Plugin Name:	DesignThemes Core Features Plugin 
 * URI: 		http://wedesignthemes.com/plugins/designthemes-core-features 
 * Description: A simple wordpress plugin designed to implements <strong>core features of DesignThemes</strong> 
 * Version: 	2.0
 * Author: 		DesignThemes
 * Text Domain: dental-core
 * Author URI:	http://themeforest.net/user/designthemes
 */
if (! class_exists ( 'DTCorePlugin' )) {

	/**
	 * Basic class to load Shortcodes & Custom Posts
	 *
	 * @author iamdesigning11
	 */
	class DTCorePlugin {

		function __construct() {
			
			$this->plugin_dir_path = plugin_dir_path ( __FILE__ );

			// Add Hook into the 'init()' action
			add_action ( 'init', array (
					$this, 'dtLoadPluginTextDomain'
			) );

			// Register Shortcodes
			require_once plugin_dir_path ( __FILE__ ) . '/shortcodes/register-shortcodes.php';
			if (class_exists ( 'DTCoreShortcodes' )) {
				$dt_core_shortcodes = new DTCoreShortcodes ();
			}

			// Register Custom Post Types
			require_once plugin_dir_path ( __FILE__ ) . '/custom-post-types/register-post-types.php';
			if (class_exists ( 'DTCoreCustomPostTypes' )) {
				$dt_core_custom_posts = new DTCoreCustomPostTypes ();
			}

			if( $this->dt_core_is_plugin_active('js_composer/js_composer.php') ) {
				// Register Visual Composer Modules
				require_once plugin_dir_path ( __FILE__ ) . '/visual-composer/register-vc.php';
				if (class_exists ( 'DTCoreVC' )) {
					new DTCoreVC ();
				}			
			}

			// Register Likes
			require_once plugin_dir_path( __FILE__ ).'/register-likes.php';

			// Register Privacy
			require_once plugin_dir_path( __FILE__ ).'/privacy/register-privacy.php';

			// Register Metabox Modules
			require_once( plugin_dir_path ( __FILE__ ) . '/metaboxes/post-metabox.php' );
			require_once( plugin_dir_path ( __FILE__ ) . '/metaboxes/page-metabox.php' );
			if( $this->dt_core_is_plugin_active('the-events-calendar/the-events-calendar.php') ) {
				require_once( plugin_dir_path ( __FILE__ ) . '/metaboxes/event-metabox.php' );
			}

			add_action( 'widgets_init', array( $this, 'dt_widgets_init' ) );

			require_once( plugin_dir_path ( __FILE__ ) .'/widgets/widget-twitter.php' );
			require_once( plugin_dir_path ( __FILE__ ) .'/widgets/widget-flickr.php' );
			require_once( plugin_dir_path ( __FILE__ ) .'/widgets/widget-recent-posts.php' );
			require_once( plugin_dir_path ( __FILE__ ) .'/widgets/widget-recent-portfolios.php' );
		}

		function dt_core_is_plugin_active($plugin) {
			return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || $this->dt_core_is_plugin_active_for_network( $plugin );
		}

		function dt_core_is_plugin_active_for_network( $plugin ) {
			if ( !is_multisite() )
				return false;

			$plugins = get_site_option( 'active_sitewide_plugins');
			if ( isset($plugins[$plugin]) )
				return true;

			return false;
		}

		function dt_widgets_init() {
			register_widget('Dental_Twitter');
			register_widget('Dental_Flickr');
			register_widget('Dental_Recent_Posts');
			register_widget('Dental_Portfolio_Widget');
		}

		/**
		 * To load text domain
		 */
		function dtLoadPluginTextDomain() {
			load_plugin_textdomain ( 'dental-core', false, dirname ( plugin_basename ( __FILE__ ) ) . '/languages/' );
		}

		/**
		 */
		public static function dtCorePluginActivate() {
		}

		/**
		 */
		public static function dtCorePluginDectivate() {
		}		
	}
}

if (class_exists ( 'DTCorePlugin' )) {

	register_activation_hook ( __FILE__, array (
			'DTCorePlugin',
			'dtCorePluginActivate' 
	) );
	register_deactivation_hook ( __FILE__, array (
			'DTCorePlugin',
			'dtCorePluginDectivate' 
	) );
	
	$dt_core_plugin = new DTCorePlugin ();
}
?>