<?php
/**
 * bicycle-rental $wp_customize Theme Customizer object
 *
 * @since Bicycle Rental 1.0.0
 */
if (!defined('ABSPATH')) {
    exit;
}


function bicycle_rental_customize_register( $wp_customize ) {
    $wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
    $wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
}
add_action( 'customize_register', 'bicycle_rental_customize_register' );

//Load All Individual Settings Based on Sections/Panels.
require_once get_stylesheet_directory().'/inc/customizer/customize.php';
require_once get_stylesheet_directory().'/inc/customizer/_sanitization.php';

/**
 * Return the dynamic css added from options.
 *
 * @since 1.0.0
 */
function bicycle_rental_dynamic_style(){

    $bicycle_rental_header_bg = get_theme_mod('bicycle_rental_header_bg');
    $bicycle_rental_header_menu = get_theme_mod('bicycle_rental_header_menu');
    $bicycle_rental_header_menu_hover = get_theme_mod('bicycle_rental_header_menu_hover');
    $bicycle_rental_header_submenu_color = get_theme_mod('bicycle_rental_header_submenu_color');
    $bicycle_rental_header_submenu_color_hover = get_theme_mod('bicycle_rental_header_submenu_color_hover');
    $bicycle_rental_header_submenu_bg_color = get_theme_mod('bicycle_rental_header_submenu_bg_color');
    $bicycle_rental_body_color = get_theme_mod('bicycle_rental_body_color');
    $bicycle_rental_headings_color = get_theme_mod('bicycle_rental_headings_color');
    $bicycle_rental_body_font = get_theme_mod('bicycle_rental_body_font');
    $bicycle_rental_full_header = get_theme_mod('bicycle_rental_full_header');

    $bicycle_rental_container_width = get_theme_mod('bicycle_rental_container_width');

    $bicycle_rental_section_bg = get_theme_mod('bicycle_rental_section_bg');

    $bicycle_rental_footer_bg = get_theme_mod('bicycle_rental_footer_bg');
    $bicycle_rental_footer_text = get_theme_mod('bicycle_rental_footer_text');
    $bicycle_rental_footer_link = get_theme_mod('bicycle_rental_footer_link');
    $bicycle_rental_footer_link_hover = get_theme_mod('bicycle_rental_footer_link_hover');
    $bicycle_rental_full_footer = get_theme_mod('bicycle_rental_full_footer');

    ob_start();
    ?>

    <?php if (!empty($bicycle_rental_headings_font_family)) { ?>
        h1, h2,
        h3, h4,
        h5, h6{
        font-family: "<?php echo esc_attr($bicycle_rental_headings_font_family); ?>", Arial, sans-serif;
    }
<?php } ?>

<?php if (!empty($bicycle_rental_body_font_family)) { ?>
    body{
    font-family: "<?php echo esc_attr($bicycle_rental_body_font_family); ?>", Arial, sans-serif;
}
<?php } ?>
:root {
    <?php if($bicycle_rental_container_width){?>
        --responsive--aligndefault-width:<?php echo esc_attr($bicycle_rental_container_width);?>px !important;
    <?php }?>
}
<?php if($bicycle_rental_container_width){?>
    .blog .content-area,
    .single .content-area,
    .search .content-area{
        max-width:<?php echo esc_attr($bicycle_rental_container_width);?>px !important; 
        margin:auto;
    }
<?php } ?>
<?php if($bicycle_rental_section_bg){ ?>
    #faq-section, #list-info, #casino-offer, #casino-ratings,
    #casino-pros-cons{
    background-color: <?php echo esc_attr($bicycle_rental_section_bg); ?>;
}
<?php } ?>

<?php if($bicycle_rental_header_bg){ ?>
    #masthead{
    background-color: <?php echo esc_attr($bicycle_rental_header_bg); ?>
}
<?php } ?>


<?php if($bicycle_rental_full_header){?>
    #masthead{
        max-width:100%;
    }
<?php } ?>

<?php if($bicycle_rental_header_menu){ ?>
    .site-branding h1,
    .primary-navigation .primary-menu-container ul .menu-item a,
    .primary-navigation .primary-menu-container ul .menu-item a:after{
        color: <?php echo esc_attr($bicycle_rental_header_menu); ?>
    }
    .menu-menu span{
        background-color: <?php echo esc_attr($bicycle_rental_header_menu); ?>
    }
<?php } ?>

<?php if($bicycle_rental_header_menu_hover){ ?>
    #site-navigation .current_page_item > a, #site-navigation .current-menu-item > a, #site-navigation .current_page_ancestor > a, 
    #site-navigation ul li.current_page_item > a::after, #site-navigation ul li.current-menu-item > a::after, 
    #site-navigation ul li.current_page_ancestor > a::after,
    #site-navigation ul li > a:hover,
    #site-navigation ul li ul.sub-menu a:hover, #site-navigation ul li ul.children a:hover,
    #site-navigation ul li.menu-item-has-children > a:hover:after{
        color: <?php echo esc_attr($bicycle_rental_header_menu_hover); ?>
    }
<?php } ?>

<?php if($bicycle_rental_header_submenu_color){ ?>
    #site-navigation ul li ul.sub-menu li a, 
    #site-navigation ul li ul.children li a{
    color: <?php echo esc_attr($bicycle_rental_header_submenu_color); ?>
    }
<?php } ?>

<?php if($bicycle_rental_header_submenu_color_hover){ ?>
    #site-navigation ul li ul.sub-menu a:hover, 
    #site-navigation ul li ul.children a:hover{
    color: <?php echo esc_attr($bicycle_rental_header_submenu_color_hover); ?>
}
<?php } ?>

<?php if($bicycle_rental_header_submenu_bg_color){?>
    .primary-navigation > div > .menu-wrapper > li > .sub-menu li.menu-item{
        background-color:<?php echo esc_attr($bicycle_rental_header_submenu_bg_color); ?>
    }
<?php }?>

<?php if($bicycle_rental_body_color){ ?>
    body{
    color: <?php echo esc_attr($bicycle_rental_body_color); ?>
}
<?php } ?>

<?php if($bicycle_rental_headings_color){ ?>
    h1, h2, h3, h4, b, strong,
    h1 a, h2 a, h3 a, h4 a,
    h5 a, h6 a, h5, h6, label{
    color: <?php echo esc_attr($bicycle_rental_headings_color); ?>
}
<?php } ?>

<?php if($bicycle_rental_body_font){ ?>
    body{
    font-size: <?php echo esc_attr($bicycle_rental_body_font); ?>px;
}
<?php } ?>

<?php if($bicycle_rental_footer_bg){ ?>    
    footer#colophon,
    aside.widget-area.footer-widgets{
    background-color:<?php echo esc_attr($bicycle_rental_footer_bg);?>
}
<?php }?>
<?php if($bicycle_rental_footer_text){ ?>    
    footer#colophon,
    footer#colophon *,
    footer#colophon p,
    aside.widget-area.footer-widgets p,
    aside.widget-area.footer-widgets *{
        color: <?php echo esc_attr($bicycle_rental_footer_text);?>
    }
<?php }?>

<?php if($bicycle_rental_footer_link){?>
    footer#colophon a,
    aside.widget-area.footer-widgets a,
    .widget h2:before{
        color: <?php echo esc_attr($bicycle_rental_footer_link);?>
    }
    .widget h2:after{
        background-color: <?php echo esc_attr($bicycle_rental_footer_link);?>
    }
<?php } ?>

<?php if($bicycle_rental_footer_link_hover){?>
    footer#colophon a:hover,
    aside.widget-area.footer-widgets a:hover{
        color: <?php echo esc_attr($bicycle_rental_footer_link_hover);?>
    }
<?php } ?>

<?php if($bicycle_rental_full_footer){ ?>
    aside.widget-area.footer-widgets,
    footer#colophon{
        max-width:100%;
}
<?php }?>

<?php
$content = apply_filters('bicycle-rental/filters/dynamic_css', ob_get_clean());
$content = str_replace(array("\r\n", "\r"), "\n", $content);
$lines = explode("\n", $content);
$dynamic_css = array();
foreach ($lines as $i => $line) {
    if (!empty($line)) {
        $dynamic_css[] = trim($line);
    }
}
return implode($dynamic_css);
}