<?php
/***
 * Custom Styles
 *
 * Get custom styles from theme options
 * in the <head> area of the theme.
 *
 */
// No direct access, yes
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

// Render Custom Style Setting
add_action( 'wp_enqueue_scripts', 'pmthemes_custom_styling');
function pmthemes_custom_styling() {
    // Get Theme Options from Database
    $theme_options = pmthemes_theme_options();
    // Get Default Fonts from settings
    $theme_def = pmthemes_default_options();
    // Set Font CSS Variable
    $mystyle_css = '';
    // Header Top Border Color and Height
    if ( isset($theme_options['header_top_border_enable']) and $theme_options['header_top_border_enable'] == $theme_def['gen_check_yes'] ) :
        $mystyle_css .= '
            #header-wrap {
                border-top: '. $theme_options['header_topbo_height'] .'px solid '. $theme_options['header_topbo'] .';
            }';
    endif;
    // Header Bottom Border Color and Height
    if ( isset($theme_options['header_bottom_border_enable']) and $theme_options['header_bottom_border_enable'] == $theme_def['gen_check_yes'] ) :
        $mystyle_css .= '
            #header-wrap {
                border-bottom: '. $theme_options['header_bottom_bor_height'] .'px solid '. $theme_options['header_bottom_border'] .';
            }';
    endif;
    // Header Padding
    if ( isset($theme_options['header_adjust']) and $theme_options['header_adjust'] == $theme_def['gen_check_yes'] ) :
        $mystyle_css .= '
            #header, .wide-header #header {padding: '. $theme_options['header_padding_top'] .'em '. $theme_options['header_padding_right'] .'em ' . $theme_options['header_padding_bottom'] .'em '. $theme_options['header_padding_left'] .'em;}';
    endif;
    // Logo & Banner Balance
    if ( isset($theme_options['logo_title_width']) and $theme_options['logo_title_width'] <> $theme_def['logo_title_width'] ) :
        $mystyle_css .= '
            @media only screen and (min-width: 60em){
            #logo {
                max-width: ' . $theme_options['logo_title_width'] . '%;
            }
            #header-banner, #header #navi-wrap {
                max-width: calc(100% - ' . $theme_options['logo_title_width'] . '%);
            }}';
    endif;
    // Site Title Font Size
    if ( isset($theme_options['title_font_size']) and $theme_options['title_font_size'] <> $theme_def['title_font_size']) :
        $mystyle_css .= '
            #logo .site-title {
                font-size: calc(' . $theme_options['title_font_size_mobile'] . 'px + (' . $theme_options['title_font_size'] . ' - ' . $theme_options['title_font_size_mobile'] . ') * ((100vw - 300px) / (1555 - 320)));
            }';
    endif;
    // Site Title Font Spacing
    if ( isset($theme_options['title_font_space']) and $theme_options['title_font_space'] <> $theme_def['title_font_space'] ) :
        $mystyle_css .= '
            @media only screen and (min-width: 60em){
            #logo .site-title {
                letter-spacing: ' . $theme_options['title_font_space'] . 'px;
            }}';
    endif;
    // Site Description Font Size
    if ( isset($theme_options['title_describe_size']) and $theme_options['title_describe_size'] <> $theme_def['title_describe_size']) :
        $mystyle_css .= '
            #logo .site-description {
                font-size: calc(14px + (' . $theme_options['title_describe_size'] . ' - 14) * ((100vw - 320px) / (1555 - 320)));
            }';
    endif;
    // Top Navigation Settings
    if ( isset($theme_options['topmenu_font_size']) and $theme_options['topmenu_font_size'] <> $theme_def['topmenu_font_size'] ) :
        $mystyle_css .= '
            #topnav-menu a, .topinner .social-icons-menu li a {
                font-size: ' . $theme_options['topmenu_font_size'] . 'em;
                padding: ' . $theme_options['topmenu_bar_padding'] . 'em;
            }';
    endif;
    // Main Navigation Settings
    if ( isset($theme_options['mainmenu_font_size']) and $theme_options['mainmenu_font_size'] <> $theme_def['mainmenu_font_size'] ) :
        $mystyle_css .= '
            .nav-menu li a {
                font-size: ' . $theme_options['mainmenu_font_size'] . 'em;
                padding: ' . $theme_options['mainmenu_bar_padding'] . 'em;
            }';
    endif;
    // Main Navigation Search Icon
    if ( isset($theme_options['search_icon']) and $theme_options['search_icon'] == true ) :
        $mystyle_css .= '
            .main-navigation {
                margin-right: 1em;
            }';
    endif;
    // Hide Dropdown Indicator
    if ( isset($theme_options['no_drpdown_ind']) and $theme_options['no_drpdown_ind'] == true ) :
        $mystyle_css .= '
            .nav-menu li.menu-item-has-children > a:after, .nav-menu .submenu li.menu-item-has-children > a:after {
                display: none;
            }';
    endif;
    // Set Content vs Sidebar Width
    if ( isset($theme_options['sidecon_width']) and $theme_options['sidecon_width'] <> $theme_def['sidecon_width'] ) :
        $mystyle_css .= '
            @media only screen and (min-width: 60em){
            #content {
                width: calc(100% - ' . $theme_options['sidecon_width'] . '%);
            }
            .rlayout #sidebar {
                width: ' . $theme_options['sidecon_width'] . '%;
                margin-right: calc(100% - ' . $theme_options['sidecon_width'] . '%);
            }
            #sidebar {
                width: ' . $theme_options['sidecon_width'] . '%;
                margin-left:calc(100% - ' . $theme_options['sidecon_width'] . '%);
            }
            }';
    endif;
    // Remove Wide Header Body Margin
    if ( isset($theme_options['no_body_margin']) and $theme_options['no_body_margin'] == $theme_def['gen_check_yes']) :
        $mystyle_css .= '
            .wide-header #content-wrap {
                margin: 0 auto;
            }';
    endif;
    // Remove Wide Header Border and Shadow
    if ( isset($theme_options['no_body_border']) and $theme_options['no_body_border'] == $theme_def['gen_check_yes']) :
        $mystyle_css .= '
            #wrapper, .wide-header #wrap, .wide-header #content-wrap {
                -webkit-box-shadow: none;
                 box-shadow: none;
                 border: none;
            }';
    endif;
    // Sidebar Padding
    if ( isset($theme_options['sidebar_padding_adjust']) and $theme_options['sidebar_padding_adjust'] == $theme_def['gen_check_yes'] ) :
        $mystyle_css .= '
            #sidebar {
                padding: '. $theme_options['sidebar_padding_top'] .'em '. $theme_options['sidebar_padding_right'] .'em '.
            $theme_options['sidebar_padding_bottom'] .'em '. $theme_options['sidebar_padding_left'] .'em;
            }';
    endif;
    // Post Title Font Size
    if ( isset($theme_options['posts_title_font_size']) and $theme_options['posts_title_font_size'] <> $theme_def['posts_title_font_size'] ) :
        $mystyle_css .= '
            .page-title, .post-title {
                font-size: ' . $theme_options['posts_title_font_size'] .'em;
            }';
    endif;
    // Products Title Font Size
    if ( isset($theme_options['product_title_font_size']) and $theme_options['product_title_font_size'] <> $theme_def['product_title_font_size'] ) :
        $mystyle_css .= '
            .woocommerce div.product .product_title {
                font-size: ' . $theme_options['product_title_font_size'] .'em;
            }';
    endif;
    // Posts/Pages Font Size
    if ( isset($theme_options['entry_font_sizes']) and $theme_options['entry_font_sizes'] <> $theme_def['entry_font_sizes'] ) :
        $mystyle_css .= '
            .entry p, .entry li, .entry tr td, code, pre, dd, dt, strong,.entry thead th, .entry tr th,
            address, .comment p,.comment li, .comment tr td, .bypostauthor .fn,
            .comment-author-admin .fn, .comment-author .fn {
                font-size: ' . $theme_options['entry_font_sizes'] .'em;
            }';
    endif;
    // Front Page Small Post Title Font Size
    if ( isset($theme_options['front_page_font_size']) and $theme_options['front_page_font_size'] <> $theme_def['front_page_font_size'] ) :
        $mystyle_css .= '
            .widget-category-posts .small-post .post-title {
                font-size: ' . $theme_options['front_page_font_size'] .'em;
            }';
    endif;
    // Front Page Big Post Title Font Size
    if ( isset($theme_options['front_page_fonts_size']) and $theme_options['front_page_fonts_size'] <> $theme_def['front_page_fonts_size'] ) :
        $mystyle_css .= '
            .widget-category-posts .big-post .post-title {
                font-size: ' . $theme_options['front_page_fonts_size'] .'em;
            }';
    endif;
    // Front Page Single Posts Title Font Size
    if ( isset($theme_options['front_posts_font_size']) and $theme_options['front_posts_font_size'] <> $theme_def['front_posts_font_size'] ) :
        $mystyle_css .= '
            #widget-category-posts-single .single-post .post-title {
                font-size: ' . $theme_options['front_posts_font_size'] .'em;
            }';
    endif;
    // Front Page Header Bar Font Size
    if ( isset($theme_options['frontbar_font_size']) and $theme_options['frontbar_font_size'] <> $theme_def['frontbar_font_size'] ) :
        $mystyle_css .= '
            #frontpage-magazine-widgets .widget .widgettitle {
                font-size: ' . $theme_options['frontbar_font_size'] . 'em;
            }';
    endif;
    // Frontpage Widget Header Font Padding
    if ( isset($theme_options['fpbar_font_pad_top']) and $theme_options['fpbar_font_pad_top'] <> $theme_def['fpbar_font_pad_top'] or
        isset($theme_options['fpbar_font_pad_right']) and $theme_options['fpbar_font_pad_right'] <> $theme_def['fpbar_font_pad_right'] or
        isset($theme_options['fpbar_font_pad_bottom']) and $theme_options['fpbar_font_pad_bottom'] <> $theme_def['fpbar_font_pad_bottom'] or
        isset($theme_options['fpbar_font_pad_left']) and $theme_options['fpbar_font_pad_left'] <> $theme_def['fpbar_font_pad_left'] ) :
        $mystyle_css .= '
            #frontpage-magazine-widgets .widget .widgettitle {padding: ' . $theme_options['fpbar_font_pad_top'] . 'px ' . $theme_options['fpbar_font_pad_right'] . 'px ' . $theme_options['fpbar_font_pad_bottom'] . 'px ' . $theme_options['fpbar_font_pad_left'] . 'px;}';
    endif;
    // Sidebar Header Bar Font Size
    if ( isset($theme_options['wgtbar_font_size']) and $theme_options['wgtbar_font_size'] <> $theme_def['wgtbar_font_size'] ) :
        $mystyle_css .= '
            #sidebar .widget .widgettitle {
                font-size: ' . $theme_options['wgtbar_font_size'] . 'em;
            }';
    endif;
    // Sidebar Header Bar Font Padding
    if ( isset($theme_options['sidebar_font_pad_top']) and $theme_options['sidebar_font_pad_top'] <> $theme_def['sidebar_font_pad_top'] or
        isset($theme_options['sidebar_font_pad_right']) and $theme_options['sidebar_font_pad_right'] <> $theme_def['sidebar_font_pad_right'] or
        isset($theme_options['sidebar_font_pad_bottom']) and $theme_options['sidebar_font_pad_bottom'] <> $theme_def['sidebar_font_pad_bottom'] or
        isset($theme_options['sidebar_font_pad_left']) and $theme_options['sidebar_font_pad_left'] <> $theme_def['sidebar_font_pad_left'] ) :
        $mystyle_css .= '
            #sidebar .widget .widgettitle {padding: ' . $theme_options['sidebar_font_pad_top'] . 'px ' . $theme_options['sidebar_font_pad_right'] . 'px ' . $theme_options['sidebar_font_pad_bottom'] . 'px ' . $theme_options['sidebar_font_pad_left'] . 'px;}';
    endif;
    if ( isset($theme_options['tabbed_font_size']) and $theme_options['tabbed_font_size'] <> $theme_def['tabbed_font_size'] ) :
        $mystyle_css .= '
            .widget-tabnavi {
                font-size: ' . $theme_options['tabbed_font_size'] . 'em;
            }';
    endif;
    if ( isset($theme_options['side_tabbed_padding']) and $theme_options['side_tabbed_padding'] <> $theme_def['side_tabbed_padding'] ) :
        $mystyle_css .= '
            .widget-tabnav li a {
                padding: ' . $theme_options['side_tabbed_padding'] . 'em;
            }';
    endif;
    // Print Font CSS
    if ( $mystyle_css ) {
        wp_add_inline_style( 'pmthemes-custom', $mystyle_css );
    }
}


