<?php 
/**  Theme defaults values  **/

add_action('after_setup_theme', 'health_theme_defaults');
function health_theme_defaults(){
	
	// Colors and Fonts
	update_option( 'health_default_main_color', '#2986e2' );
	update_option( 'health_default_gradient_color', '' );
	update_option( 'health_default_additional_color', '#f26529' );
	update_option( 'health_default_font', 'Lato' );
	update_option( 'health_default_font_weights', '300,400,500,700,900' );
	update_option( 'health_default_font_weight', '400' );
	update_option( 'health_default_title', 'Raleway' );
	update_option( 'health_default_title_weights',  '300,400,500,700,900'  );
	update_option( 'health_default_title_weight', '500' );
	update_option( 'health_default_subtitle', 'Raleway' );
	update_option( 'health_default_title_weights',  '300,400,500,700,900'  );
	update_option( 'health_default_subtitle_weight', '500' );
	
	// Header Title and Breadcrumbs
	update_option( 'health_default_tab_bg_color', '#000000' );
	update_option( 'health_default_tab_bg_color_gradient', '' );
	update_option( 'health_default_tab_gradient_direction', 'to bottom' );
	update_option( 'health_default_tab_bg_opacity', '0.8' );
	update_option( 'health_default_tab_padding_top', '200' );
	update_option( 'health_default_tab_padding_bottom', '50' );
	update_option( 'health_default_tab_margin_bottom', '80' );
	update_option( 'health_default_tab_bottom_decor', '1' );
	update_option( 'health_default_tab_border', '1' );

	update_option( 'health_page_loader_bg_color', '#ffffff' );

}

add_filter( 'health_header_settings', 'health_header_settings_var' );
function health_header_settings_var( $post_ID=0 ){

	if(isset($post_ID) && $post_ID>0) {

		/// Header global parameters
		$health['header_type'] = get_post_meta($post_ID, 'header_type', 1) != '' ? get_post_meta($post_ID, 'header_type', 1) : health_get_option('header_type', 'header1');
		$health['header_sidebar_view'] = $health['header_type'] == 'header3' ? (get_post_meta($post_ID, 'header_sidebar_view', 1) != '' ? get_post_meta($post_ID, 'header_sidebar_view', 1) : health_get_option('header_sidebar_view', 'fixed')) : '';
		$health['header_background'] = get_post_meta($post_ID, 'header_background', 1) != '' ? get_post_meta($post_ID, 'header_background', 1) : (health_get_option('header_background', 'trans-black'));
		$health['header_transparent'] = get_post_meta($post_ID, 'header_transparent', 1) != '' ? get_post_meta($post_ID, 'header_transparent', 1) : health_get_option('header_transparent', '4');
		$health['header_hover_effect'] = get_post_meta($post_ID, 'header_hover_effect', 1) != '' ? get_post_meta($post_ID, 'header_hover_effect', 1) : health_get_option('header_hover_effect', '0');
		$health['header_marker'] = get_post_meta($post_ID, 'header_marker', 1) != '' ? get_post_meta($post_ID, 'header_marker', 1) : health_get_option('header_marker', 'menu-marker-arrow');
		$health['header_layout'] = get_post_meta($post_ID, 'header_layout', 1) != '' ? get_post_meta($post_ID, 'header_layout', 1) : health_get_option('header_layout', 'normal');
		$health['header_bar'] = get_post_meta($post_ID, 'header_bar', 1) != '' ? get_post_meta($post_ID, 'header_bar', 1) : health_get_option('header_bar', '0');

		$health['header_sticky'] = get_post_meta($post_ID, 'header_sticky', 1) != '' ? get_post_meta($post_ID, 'header_sticky', 1) : health_get_option('header_sticky', 'sticky');
		$health['mobile_sticky'] = get_post_meta($post_ID, 'mobile_sticky', 1) != '' ? get_post_meta($post_ID, 'mobile_sticky', 1) : health_get_option('mobile_sticky', '');


		/// Header menu settings
		$health['header_menu'] = get_post_meta($post_ID, 'header_menu', 1) != '' ? get_post_meta($post_ID, 'header_menu', 1) : health_get_option('header_menu', '1');
		$health['header_menu_add'] = get_post_meta($post_ID, 'header_menu_add', 1) != '' ? get_post_meta($post_ID, 'header_menu_add', 1) : health_get_option('header_menu_add', '');
		$health['header_menu_add_position'] = get_post_meta($post_ID, 'header_menu_add_position', 1) != '' ? get_post_meta($post_ID, 'header_menu_add_position', 1) : health_get_option('header_menu_add_position', 'disable');
		$health['header_menu_animation'] = get_post_meta($post_ID, 'header_menu_animation', 1) != '' ? get_post_meta($post_ID, 'header_menu_animation', 1) : health_get_option('header_menu_animation', 'overlay');

		/// Header widgets
		$health['header_minicart'] = get_post_meta($post_ID, 'header_minicart', 0) != '' ? get_post_meta($post_ID, 'header_minicart', 1) : health_get_option('header_minicart', '1');
		$health['header_search'] = get_post_meta($post_ID, 'header_search', 0) != '' ? get_post_meta($post_ID, 'header_search', 1) : health_get_option('header_search', '0');
		$health['header_socials'] = get_post_meta($post_ID, 'header_socials', 1) != '' ? get_post_meta($post_ID, 'header_socials', 1) : health_get_option('header_socials', '1');


		$class = '';
		foreach ($health as $key => $val) {
			if (!in_array($key, array('header_transparent', 'header_sticky', 'mobile_sticky', 'header_menu_animation')))
				$class .= $val . '-';
		}
		$health['header_uniq_class'] = substr($class, 0, -1);

		$health['header_phone'] = get_post_meta($post_ID, 'header_phone', 1) != '' ? get_post_meta($post_ID, 'header_phone', 1) : health_get_option('header_phone', '');
		$health['header_email'] = get_post_meta($post_ID, 'header_email', 1) != '' ? get_post_meta($post_ID, 'header_email', 1) : health_get_option('header_email', '');

		/// Header elements position
		$health['header_topbarbox_1_position'] = get_post_meta($post_ID, 'header_topbarbox_1_position', 1) != '' ? get_post_meta($post_ID, 'header_topbarbox_1_position', 1) : health_get_option('header_topbarbox_1_position', 'left', 0);
		$health['header_topbarbox_2_position'] = get_post_meta($post_ID, 'header_topbarbox_2_position', 1) != '' ? get_post_meta($post_ID, 'header_topbarbox_2_position', 1) : health_get_option('header_topbarbox_2_position', 'right', 0);
		$health['header_navibox_1_position'] = get_post_meta($post_ID, 'header_navibox_1_position', 1) != '' ? get_post_meta($post_ID, 'header_navibox_1_position', 1) : health_get_option('header_navibox_1_position', 'left');
		$health['header_navibox_2_position'] = get_post_meta($post_ID, 'header_navibox_2_position', 1) != '' ? get_post_meta($post_ID, 'header_navibox_2_position', 1) : health_get_option('header_navibox_2_position', 'right');
		$health['header_navibox_3_position'] = get_post_meta($post_ID, 'header_navibox_3_position', 1) != '' ? get_post_meta($post_ID, 'header_navibox_3_position', 1) : health_get_option('header_navibox_3_position', 'right');
		$health['header_navibox_4_position'] = get_post_meta($post_ID, 'header_navibox_4_position', 1) != '' ? get_post_meta($post_ID, 'header_navibox_4_position', 1) : health_get_option('header_navibox_4_position', 'right');

		/// Responsive
		$health['mobile_sticky'] = get_post_meta($post_ID, 'mobile_sticky', 1) != '' ? get_post_meta($post_ID, 'mobile_sticky', 1) : health_get_option('mobile_sticky', '');
		$health['mobile_topbar'] = get_post_meta($post_ID, 'mobile_topbar', 1) != '' ? get_post_meta($post_ID, 'mobile_topbar', 1) : health_get_option('mobile_topbar', '');
		$health['tablet_minicart'] = get_post_meta($post_ID, 'tablet_minicart', 1) != '' ? get_post_meta($post_ID, 'tablet_minicart', 1) : health_get_option('tablet_minicart', '');
		$health['tablet_search'] = get_post_meta($post_ID, 'tablet_search', 1) != '' ? get_post_meta($post_ID, 'tablet_search', 1) : health_get_option('tablet_search', '');
		$health['tablet_phone'] = get_post_meta($post_ID, 'tablet_phone', 1) != '' ? get_post_meta($post_ID, 'tablet_phone', 1) : health_get_option('tablet_phone', '');
		$health['tablet_socials'] = get_post_meta($post_ID, 'tablet_socials', 1) != '' ? get_post_meta($post_ID, 'tablet_socials', 1) : health_get_option('tablet_socials', '');


		/// Logo
		$health['logo'] = get_post_meta($post_ID, 'header_logo', 1) != '' ? get_post_meta($post_ID, 'header_logo', 1) : health_get_option('general_settings_logo', '');
		$health['logo_inverse'] = get_post_meta($post_ID, 'header_logo_inverse', 1) != '' ? get_post_meta($post_ID, 'header_logo_inverse', 1) : health_get_option('general_settings_logo_inverse', '');


		return $health;
	} else {

		/// Header global parameters
		$health['header_type'] = health_get_option('header_type', 'header1');
		$health['header_sidebar_view'] = health_get_option('header_sidebar_view', 'fixed');
		$health['header_background'] = health_get_option('header_background', 'trans-black');
		$health['header_transparent'] = health_get_option('header_transparent', '4');
		$health['header_hover_effect'] = health_get_option('header_hover_effect', '0');
		$health['header_marker'] = health_get_option('header_marker', 'menu-marker-arrow');
		$health['header_layout'] = health_get_option('header_layout', 'normal');
		$health['header_bar'] = health_get_option('header_bar', '0');

		$health['header_sticky'] = health_get_option('header_sticky', 'sticky');
		$health['mobile_sticky'] = '';

		/// Header menu settings
		$health['header_menu'] = '1';
		$health['header_menu_add'] = health_get_option('header_menu_add', '');
		$health['header_menu_add_position'] = health_get_option('header_menu_add_position', 'left');
		$health['header_menu_animation'] = health_get_option('header_menu_animation', 'overlay');

		/// Header widgets
		$health['header_minicart'] = health_get_option('header_minicart', '1');
		$health['header_search'] = health_get_option('header_search', '1');
		$health['header_socials'] = health_get_option('header_socials', '1');

		$class = '';
		foreach ($health as $key => $val) {
			if (!in_array($key, array('header_transparent', '', 'mobile_sticky', 'header_menu_animation')))
				$class .= $val . '-';
		}
		$health['header_uniq_class'] = substr($class, 0, -1);

		$health['header_phone'] = '';
		$health['header_email'] = '';

		/// Header elements position
		$health['header_topbarbox_1_position'] = 'left';
		$health['header_topbarbox_2_position'] = 'right';
		$health['header_navibox_1_position'] = 'left';
		$health['header_navibox_2_position'] = 'right';
		$health['header_navibox_3_position'] = 'right';
		$health['header_navibox_4_position'] = 'right';

		/// Responsive
		$health['mobile_sticky'] = '';
		$health['mobile_topbar'] = '';
		$health['tablet_minicart'] = '';
		$health['tablet_search'] = '';
		$health['tablet_phone'] = '';
		$health['tablet_socials'] = '';

		/// Logo
		$health['logo'] = '';
		$health['logo_inverse'] = '';

		return $health;
	}
}