<?php
/**
 * Init kentooz framework for free
 */
// Do not load directly...
if ( ! defined( 'ABSPATH' ) ) { die( 'Direct access forbidden.' ); }

/*
* Add other script
*/
require_once(get_template_directory() . '/includes/functions/BFI_Thumb.php');
// Change the upload subdirectory to wp-content/uploads/other_dir
@define( BFITHUMB_UPLOAD_DIR, 'ktz' ); 

//Automatic update
require get_template_directory() . '/includes/functions/theme-update-checker.php';
$kentooz_update_checker = new ThemeUpdateChecker (
	'kapro',
	'http://www.kentooz.com/files/kapro/kaproniehupdatechecker.json'
);

//Importer
function load_radium_one_click_demo_install(){
	require get_template_directory() . '/includes/importer/init.php';
}
add_action( 'after_setup_theme', 'load_radium_one_click_demo_install', 2 );

class KENTOOZ {
	public static function init() {
		self::ktz_definitions();
		self::ktz_functions();
		self::ktz_add_actions();
		self::ktz_filters();
		self::locale();
	}

	// Define URL
	public static function ktz_definitions() {
		define( 'theme_slug', get_template() );
		define( 'ktz_dir', get_template_directory() . '/' );
		define( 'ktz_inc', get_template_directory() . '/includes/' );
		define( 'ktz_url', get_template_directory_uri() . '/' );
		define( 'ktz_styleinc', get_template_directory_uri() . '/includes/' );
		define( 'ktz_theme_textdomain', theme_slug );
		define( 'ktz_admin_textdomain', theme_slug . '_admin' );
	}
		
	// Load function data
	public static function ktz_functions() {
		require_once(ktz_inc . 'admin/admin.php');
		require_once(ktz_inc . 'widget/widget.php');
		require_once(ktz_inc . 'shortcodes/shortcode.php');
		require_once(ktz_inc . 'functions/function_core.php');
		require_once(ktz_inc . 'functions/function_js.php');
		require_once(ktz_inc . 'functions/function_head.php');
		require_once(ktz_inc . 'functions/function_footer.php');
		require_once(ktz_inc . 'functions/function_sidebar.php');
		require_once(ktz_inc . 'functions/function_content.php');
		require_once(ktz_inc . 'functions/function_loop.php');
		require_once(ktz_inc . 'functions/function_magazine.php');
		require_once(ktz_inc . 'metaboxes/meta-options.php');
		require_once(ktz_inc . 'metaboxes/meta-theme.php');
	}	
	
	public static function ktz_add_actions() {
		add_action( 'do_ktz_after_single_content', 'ktz_comments_template' );
		add_action( 'do_ktz_after_single_content', 'ktz_comments_facebook' );
		add_action(	'after_setup_theme', 'ktz_setup' );
		add_action( 'do_ktz_mainfooter', 'ktz_mainfooter' );
		add_action( 'do_ktz_subfooter', 'ktz_subfooter',10 );
		add_action( 'do_ktz_subfooter', 'ktz_sn',15 );
		add_action( 'do_ktz_head', 'ktz_head_favicon' );
		add_action( 'wp_head', 'ktz_headelement' );
		add_action( 'wp_head', 'ktz_dynamicbg' );
		add_action( 'do_ktz_ban200200_leftmag', 'ktz_ban200200_leftmag' );
		add_action( 'do_ktz_footbanner', 'ktz_ban72890_foot' );
		add_action( 'do_ktz_centerbanner', 'ktz_centerbanner' );
		add_action( 'do_ktz_centerbanner', 'ktz_centerbanner2' );
		add_action( 'do_ktz_archivebanner', 'ktz_archivebanner' );
		add_action( 'do_ktz_topheader', 'ktz_topheader' );
		add_action( 'do_ktz_header', 'ktz_headlogo' );
		add_action( 'do_ktz_topsearch', 'ktz_topsearch' );
		add_action( 'do_ktz_secondmenu_header', 'ktz_secondmenu' );
		add_action( 'do_ktz_topmenu', 'ktz_topmenu' );
		add_action( 'wp_enqueue_scripts', 'ktz_enqueue_css' );  
		add_action( 'init', 'ktz_register_css');
		add_action( 'do_ktz_nivo', 'ktz_feat_nivoslider' );
		add_action( 'do_ktz_carousel', 'ktz_feat_fullslider' );
		add_action( 'do_ktz_after_header', 'ktz_crumbs' );
		add_action( 'init', 'ktz_register_jascripts' );
		add_action( 'wp_enqueue_scripts','ktz_jsscripts' );
		add_action( 'do_ktz_content', 'ktz_posted_title' );
		add_action( 'do_ktz_meta_content', 'ktz_author_by' );
		add_action( 'do_ktz_meta_content', 'ktz_posted_on' );	
		add_action( 'do_ktz_meta_content', 'ktz_comment_num' );
		add_action( 'do_ktz_module_ticker', 'ktz_module_ticker' );
		add_action( 'do_ktz_module_1', 'ktz_module_latest' );
		add_action( 'do_ktz_module_1', 'ktz_module_1' );
		add_action( 'do_ktz_module_2', 'ktz_module_2' );
		add_action( 'do_ktz_module_3', 'ktz_module_3' );
		add_action( 'do_ktz_module_5', 'ktz_module_5' );
		add_action( 'do_ktz_content', 'ktz_content' );	
		add_action( 'do_ktz_content', 'ktz_link_pages' );
		add_action( 'do_ktz_singlerate', 'ktz_posted_ratting' );
		add_action( 'do_ktz_singlecontent', 'ktz_content' );	
		add_action( 'do_ktz_singlecontent', 'ktz_link_pages' );
		add_action( 'do_ktz_singlecontent', 'ktz_tagged' );
		add_action( 'do_ktz_singlecontent', 'ktz_ban72890_singlefoot' );
		add_action( 'do_ktz_singlecontent', 'ktz_relpost' );
		add_action( 'do_ktz_singlecontent', 'ktz_share_post' );	
		add_action( 'do_ktz_feat_single', 'ktz_most_view' );
		add_action( 'do_ktz_feat_single', 'ktz_ban300250_singlefoot' );
		add_action( 'do_ktz_feedburner', 'ktz_feedburner' );
		add_action( 'do_ktz_navigation', 'ktz_navigation' );
		add_action( 'do_ktz_thumbfull', 'ktz_thumbfull' );
		add_action( 'widgets_init', 'sidebar_widget_init' );
		add_action( 'widgets_init', 'ktz_widget_init' );
	}
	public static function ktz_filters() {	
		add_filter( 'get_avatar', 'change_avatar_css' );
		add_filter( 'comment_form_default_fields','ktz_com_fields' );
		add_filter( 'comment_form_field_comment','ktz_com_fields_textarea' );
		add_filter( 'the_content', 'ktz_texturize_SC' );
		add_filter( 'the_content', 'ktz_formatter', 99 );
		add_filter( 'widget_text', 'ktz_formatter', 99 );
		add_filter( 'widget_text', 'do_shortcode' );
		remove_filter( 'the_content', 'wptexturize' );
		remove_filter( 'the_content', 'wpautop' );
	}
	public static function locale() {
		$locale = get_locale();
		if( is_admin() ) {
			load_theme_textdomain( ktz_admin_textdomain, ktz_inc . 'languages' );
			$locale_file = ktz_inc . "languages/$locale.php";
		} else {
			load_theme_textdomain( ktz_theme_textdomain, ktz_dir . 'languages' );
			$locale_file = ktz_dir . "languages/$locale.php";
		}
		if ( is_readable( $locale_file ) )
			require_once( $locale_file );
	}
}

// Hook system
function hook_ktz_head() {
	 do_action('do_ktz_head');
}

function hook_ktz_secondmenu_header() {
	 do_action('do_ktz_secondmenu_header');
}

function hook_do_ktz_topsearch() {
	 do_action('do_ktz_topsearch');
}

function hook_ktz_header() {
	do_action( 'do_ktz_header' );
}

function hook_ktz_menu_header() {
	do_action( 'do_ktz_topmenu' );
}

function hook_ktz_after_header() {
	 do_action(	'do_ktz_after_header' );
}
function hook_ktz_nivo() {
	 do_action( 'do_ktz_nivo' );
}
function hook_ktz_carousel() {
	 do_action( 'do_ktz_carousel' );
}
function hook_ktz_module_1() {
	 do_action( 'do_ktz_module_1' );
}
function hook_ktz_module_2() {
		do_action( 'do_ktz_module_2' );
}

function hook_ktz_module_3() {
		do_action( 'do_ktz_module_3' );
}

function hook_ktz_module_ticker() {
		do_action( 'do_ktz_module_ticker' );
}

function hook_ktz_module_5() {
		do_action( 'do_ktz_module_5' );
}
function hook_ktz_title_content() {
	 do_action('do_ktz_title_content');
}
function hook_ktz_ban200200_leftmag() {
	 do_action('do_ktz_ban200200_leftmag');
}
function hook_ktz_footbanner() {
	 do_action('do_ktz_footbanner');
}
function hook_ktz_centerbanner() {
	 do_action('do_ktz_centerbanner');
}
function hook_ktz_archivebanner() {
	 do_action('do_ktz_archivebanner');
}
function hook_ktz_meta_content() {
	 do_action('do_ktz_meta_content');
}

function hook_ktz_content() {
	 do_action('do_ktz_content');
}

function hook_ktz_singlecontent() {
	 do_action('do_ktz_singlecontent');
}
function hook_ktz_singlerate() {
	 do_action('do_ktz_singlerate');
}
function hook_ktz_feat_single() {
	 do_action('do_ktz_feat_single');
}
function hook_ktz_feedburner() {
	 do_action('do_ktz_feedburner');
}
function hook_ktz_navigation() {
	 do_action('do_ktz_navigation');
}

function hook_ktz_after_single_content() {
	 do_action('do_ktz_after_single_content');
}

function hook_ktz_footer() {
	do_action( 'do_ktz_mainfooter' ); 
}

function hook_ktz_after_footer() {
	 do_action('do_ktz_subfooter');
}