<?php
/**
 * Headerdata of Theme options.
 * @package RetroTale
 * @since RetroTale 1.0.0
*/  

// additional CSS
if(	!is_admin()){
function retrotale_fonts_include () {
// Google Fonts
$bodyfont = get_theme_mod('retrotale_body_google_fonts', retrotale_default_options('retrotale_body_google_fonts'));
$headingfont = get_theme_mod('retrotale_headings_google_fonts', retrotale_default_options('retrotale_headings_google_fonts'));
$descriptionfont = get_theme_mod('retrotale_description_google_fonts', retrotale_default_options('retrotale_description_google_fonts'));
$headlinefont = get_theme_mod('retrotale_headline_google_fonts', retrotale_default_options('retrotale_headline_google_fonts'));
$postentryfont = get_theme_mod('retrotale_postentry_google_fonts', retrotale_default_options('retrotale_postentry_google_fonts'));
$sidebarfont = get_theme_mod('retrotale_sidebar_google_fonts', retrotale_default_options('retrotale_sidebar_google_fonts'));
$menufont = get_theme_mod('retrotale_menu_google_fonts', retrotale_default_options('retrotale_menu_google_fonts'));

$fonturl = "//fonts.googleapis.com/css?family=";
$character_set = "&amp;subset=" . get_theme_mod('retrotale_character_set', retrotale_default_options('retrotale_character_set'));

$bodyfonturl = $fonturl.$bodyfont.$character_set;
$headingfonturl = $fonturl.$headingfont.$character_set;
$descriptionfonturl = $fonturl.$descriptionfont.$character_set;
$headlinefonturl = $fonturl.$headlinefont.$character_set;
$postentryfonturl = $fonturl.$postentryfont.$character_set;
$sidebarfonturl = $fonturl.$sidebarfont.$character_set;
$menufonturl = $fonturl.$menufont.$character_set;

     if ($bodyfont != 'default' && $bodyfont != ''){
      wp_enqueue_style('retrotale-google-font1', $bodyfonturl); 
		 }
     if ($headingfont != 'default' && $headingfont != ''){
      wp_enqueue_style('retrotale-google-font2', $headingfonturl);
		 }
     if ($descriptionfont != 'default' && $descriptionfont != ''){
      wp_enqueue_style('retrotale-google-font3', $descriptionfonturl);
		 }
     if ($headlinefont != 'default' && $headlinefont != ''){
      wp_enqueue_style('retrotale-google-font4', $headlinefonturl); 
		 }
     if ($postentryfont != 'default' && $postentryfont != ''){
      wp_enqueue_style('retrotale-google-font5', $postentryfonturl); 
		 }
     if ($sidebarfont != 'default' && $sidebarfont != ''){
      wp_enqueue_style('retrotale-google-font6', $sidebarfonturl);
		 }
     if ($menufont != 'default' && $menufont != ''){
      wp_enqueue_style('retrotale-google-font8', $menufonturl);
		 } 
}
add_action( 'wp_enqueue_scripts', 'retrotale_fonts_include' );
}

// additional CSS
function retrotale_css_include () {
		if ( get_theme_mod('retrotale_css', retrotale_default_options('retrotale_css')) == 'Blue' ){
			wp_enqueue_style('retrotale-style-blue', get_template_directory_uri().'/css/colors/blue.css');
		}
    
		if ( get_theme_mod('retrotale_css', retrotale_default_options('retrotale_css')) == 'Green' ){
			wp_enqueue_style('retrotale-style-green', get_template_directory_uri().'/css/colors/green.css');
		}
    
    if ( get_theme_mod('retrotale_layout', retrotale_default_options('retrotale_layout')) == 'Wide' ){
			wp_enqueue_style('retrotale-wide-layout', get_template_directory_uri().'/css/wide-layout.css');
		}
}
add_action( 'wp_enqueue_scripts', 'retrotale_css_include' );

// Outputs additional CSS based on the Theme Options panel custom settings.
function retrotale_styles_method() {

wp_enqueue_style( 'retrotale-style', get_stylesheet_uri() );

$background_color = get_background_color();
$layout_style = get_theme_mod('retrotale_layout', retrotale_default_options('retrotale_layout'));
$display_sidebar = get_theme_mod('retrotale_display_sidebar', retrotale_default_options('retrotale_display_sidebar'));
$display_sidebar_archives = get_theme_mod('retrotale_display_sidebar_archives', retrotale_default_options('retrotale_display_sidebar_archives'));
$display_meta_post_entry = get_theme_mod('retrotale_display_meta_post_entry', retrotale_default_options('retrotale_display_meta_post_entry'));
$bodyfont = get_theme_mod('retrotale_body_google_fonts', retrotale_default_options('retrotale_body_google_fonts'));
$headingfont = get_theme_mod('retrotale_headings_google_fonts', retrotale_default_options('retrotale_headings_google_fonts'));
$descriptionfont = get_theme_mod('retrotale_description_google_fonts', retrotale_default_options('retrotale_description_google_fonts'));
$headlinefont = get_theme_mod('retrotale_headline_google_fonts', retrotale_default_options('retrotale_headline_google_fonts'));
$postentryfont = get_theme_mod('retrotale_postentry_google_fonts', retrotale_default_options('retrotale_postentry_google_fonts'));
$sidebarfont = get_theme_mod('retrotale_sidebar_google_fonts', retrotale_default_options('retrotale_sidebar_google_fonts'));
$menufont = get_theme_mod('retrotale_menu_google_fonts', retrotale_default_options('retrotale_menu_google_fonts'));
$own_css = get_theme_mod('retrotale_own_css');
$own_css_def = retrotale_default_options('retrotale_own_css');

// User defined Custom CSS
if ($own_css != '') {
        $own_css_custom_css = esc_html($own_css);
        wp_add_inline_style( 'retrotale-style', $own_css_custom_css );
}
elseif ($own_css == '' && $own_css_def != '') {
        $own_css_custom_css_def = esc_html($own_css_def);
        wp_add_inline_style( 'retrotale-style', $own_css_custom_css_def );
}

// Tribe Events Month Headlines background - Wide layout
if ($background_color != '' && $layout_style == 'Wide') {
        $background_color_custom_css = "body .tribe-events-list-separator-month span { background-color: #$background_color; }";
        wp_add_inline_style( 'retrotale-style', $background_color_custom_css );
}

// Display Sidebar on Posts/Pages
if ($display_sidebar == 'Hide') {
        $display_sidebar_custom_css = ".page #container #main-content #content, .single #container #main-content #content, .error404 #container #main-content #content, .tribe-events-page-template #container #main-content #content { width: 100%; }";
        wp_add_inline_style( 'retrotale-style', $display_sidebar_custom_css );
}

// Display Sidebar on Archives
if ($display_sidebar_archives == 'Hide') {
        $display_sidebar_archives_custom_css = ".blog #container #main-content #content, .archive #container #main-content #content, .search #container #main-content #content { width: 100%; } .archive #sidebar { display: none; }";
        wp_add_inline_style( 'retrotale-style', $display_sidebar_archives_custom_css );
}

// Display Meta Box on Post Entries
if ($display_meta_post_entry == 'Hide') {
        $display_meta_post_entry_custom_css = "#wrapper #main-content .post-entry .attachment-post-thumbnail { margin-bottom: 17px; } #wrapper #main-content .post-entry .post-entry-content { margin-bottom: -4px; }";
        wp_add_inline_style( 'retrotale-style', $display_meta_post_entry_custom_css );
}

// FONTS
// Body font
if ($bodyfont != 'default' && $bodyfont != '') {
        $bodyfont_custom_css = "html body, #wrapper blockquote, #wrapper q, #wrapper #container #comments .comment, #wrapper #container #comments .comment time, #wrapper #container #commentform .form-allowed-tags, #wrapper #container #commentform p, #wrapper input, #wrapper textarea, #wrapper button, #wrapper select, #wrapper #content .breadcrumb-navigation, #wrapper #main-content .post-meta, html #wrapper .tribe-events-schedule h3, html #wrapper .tribe-events-schedule span, #wrapper #tribe-events-content .tribe-events-calendar .tribe-events-month-event-title { font-family: $bodyfont, Arial, Helvetica, sans-serif; }";
        wp_add_inline_style( 'retrotale-style', $bodyfont_custom_css );
}

// Site Title font
if ($headingfont != 'default' && $headingfont != '') {
        $headingfont_custom_css = "#wrapper .site-title { font-family: $headingfont, Arial, Helvetica, sans-serif; }";
        wp_add_inline_style( 'retrotale-style', $headingfont_custom_css );
}

// Site Description font
if ($descriptionfont != 'default' && $descriptionfont != '') {
        $descriptionfont_custom_css = "#wrapper .site-description { font-family: $descriptionfont, Arial, Helvetica, sans-serif; }";
        wp_add_inline_style( 'retrotale-style', $descriptionfont_custom_css );
}

// Page/Post Headlines font
if ($headlinefont != 'default' && $headlinefont != '') {
        $headlinefont_custom_css = "#wrapper h1, #wrapper h2, #wrapper h3, #wrapper h4, #wrapper h5, #wrapper h6, #wrapper #container .navigation .section-heading, #wrapper #comments .entry-headline { font-family: $headlinefont, Arial, Helvetica, sans-serif; }";
        wp_add_inline_style( 'retrotale-style', $headlinefont_custom_css );
}

// Post Entry Headline font
if ($postentryfont != 'default' && $postentryfont != '') {
        $postentryfont_custom_css = "#wrapper #main-content .post-entry .post-entry-headline, #wrapper #main-content .grid-entry .grid-entry-headline, html #wrapper #main-content .tribe-events-list-event-title { font-family: $postentryfont, Arial, Helvetica, sans-serif; }";
        wp_add_inline_style( 'retrotale-style', $postentryfont_custom_css );
}

// Sidebar and Footer Widget Headlines font
if ($sidebarfont != 'default' && $sidebarfont != '') {
        $sidebarfont_custom_css = "#wrapper #container #sidebar .sidebar-widget .sidebar-headline, #wrapper #wrapper-footer #footer .footer-widget .footer-headline { font-family: $sidebarfont, Arial, Helvetica, sans-serif; }";
        wp_add_inline_style( 'retrotale-style', $sidebarfont_custom_css );
}

// Main Header Menu font
if ($menufont != 'default' && $menufont != '') {
        $menufont_custom_css = "#wrapper #header .menu-box ul li a { font-family: $menufont, Arial, Helvetica, sans-serif; }";
        wp_add_inline_style( 'retrotale-style', $menufont_custom_css );
}

}
add_action( 'wp_enqueue_scripts', 'retrotale_styles_method' ); ?>