<?php

include_once THEMEMAKERS_THEME_PATH . '/admin/extensions/helper.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/extensions/helper_fonts.php';
//***
//include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_portfolio.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_testimonials.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_game.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_review.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_release.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_preview.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_gallery.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_rating.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_page.php';
//---
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_slider.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_contact_form.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_custom_sidebars.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_page_constructor.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/entities/entity_seo_group.php';
//+++
include_once THEMEMAKERS_THEME_PATH . '/admin/classes/taxonomy_term_types.php';
include_once THEMEMAKERS_THEME_PATH . '/admin/classes/user.php';
//***
include_once THEMEMAKERS_THEME_PATH . '/admin/theme_widgets.php';
//APPLICATIONS INCLUDING
include_once THEMEMAKERS_APPLICATION_PATH . '/includer.php';
//*****
//POST TYPES REGISTRATION
add_action('init', array('ThemeMakersThemeModel', 'register'));
add_action('init', array('Thememakers_Entity_Testimonials', 'register'));
add_action('init', array('Thememakers_Entity_Gallery', 'register'));
add_action('init', array('Thememakers_Entity_Game', 'register'));
add_action('init', array('Thememakers_Entity_Review', 'register'));
add_action('init', array('Thememakers_Entity_Release', 'register'));
add_action('init', array('Thememakers_Entity_Preview', 'register'));
add_action('init', array('ThemeMakersUser', 'init'));
add_action("admin_init", "thememakers_admin_init");
add_action('save_post', 'thememakers_save_details');
//ThemeMakersUser::init();

function thememakers_admin_init() {
		
				//static attributes
		$before_widget = '<div id="%1$s" class="widget %2$s">';
		$after_widget = '</div>';
		$before_title = '<h3 class="widget-title">';
		$after_title = '</h3>';

    Thememakers_Entity_Gallery::init_meta_boxes();
    Thememakers_Entity_Page::init_meta_boxes();
    Thememakers_Entity_Page_Constructor::init_meta_boxes();
    //*****
    Thememakers_Entity_Game::init_meta_boxes();
    Thememakers_Entity_Review::init_meta_boxes();
    Thememakers_Entity_Release::init_meta_boxes();
    Thememakers_Entity_Preview::init_meta_boxes();
	
	
$widget_areas = Thememakers_Entity_Custom_Sidebars::register_custom_sidebars($before_widget, $after_widget, $before_title, $after_title);
    //*****
}

function thememakers_save_details() {
	if (!empty($_POST)) {
        if (isset($_POST['thememakers_meta_saving'])) {
            global $post;
            $post_type = get_post_type($post->ID);
            switch ($post_type) {
                case 'testimonials':
                    Thememakers_Entity_Testimonials::save($post->ID);
                    break;
                case 'games':
                    Thememakers_Entity_Game::save($post->ID);
                case 'review':
                    Thememakers_Entity_Review::save($post->ID);
                case 'release':
                    Thememakers_Entity_Release::save($post->ID);
                case 'pre-view':
                    Thememakers_Entity_Preview::save($post->ID);
                case 'gall':
                    Thememakers_Entity_Gallery::save($post->ID);
                case 'page':case 'post':
                    Thememakers_Entity_Page::save($post->ID); //for all types
                    break;
                default:
                    break;
            }

            Thememakers_Entity_Page_Constructor::save($post->ID);
        }
    }
}

//*****
//Remove standard image sizes so that these sizes are not created during the Media Upload process
function thememakers_filter_image_sizes($sizes) {

    unset($sizes['thumbnail']);
    unset($sizes['medium']);
    unset($sizes['large']);


    return $sizes;
}

if (ThemeMakersThemeModel::get_option('hide_wp_image_sizes')) {
    add_filter('intermediate_image_sizes_advanced', 'thememakers_filter_image_sizes');
}

//Magic with taxonomies
function get_taxonomy_term_type($taxonomy, $term_id) {
    return get_option("_term_type_{$taxonomy}_{$term_id}");
}

function update_taxonomy_term_type($taxonomy, $term_id, $value) {
    update_option("_term_type_{$taxonomy}_{$term_id}", $value);
}

ThemeMakersTaxonomyTermTypes::on_load(array('cons'));
//**********************************************************************************
remove_filter('the_content', 'wptexturize');

