<?php 

function classiera_wpcss_loaded() {

	// Return the lowest priority number from all the functions that hook into wp_head
	global $wp_filter;
	$lowest_priority = max(array_keys($wp_filter['wp_head']));
	add_action('wp_head', 'classiera_wpcss_head', $lowest_priority + 1);
 
	$arr = $wp_filter['wp_head'];

}
add_action('wp_head', "classiera_wpcss_head");

function hex2rgb($hex) {
        $hex = str_replace("#", "", $hex);

        if (strlen($hex) == 3) {
            $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
            $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
            $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
        } else {
            $r = hexdec(substr($hex, 0, 2));
            $g = hexdec(substr($hex, 2, 2));
            $b = hexdec(substr($hex, 4, 2));
        }
        $rgb = array($r, $g, $b);
        return implode(",", $rgb); // returns the rgb values separated by commas
        //return $rgb; // returns an array with the rgb values
    }
 
// wp_head callback functions
function classiera_wpcss_head() {

	global $redux_demo; 
	$classieraPrimaryColor = $redux_demo['color-primary'];
	$classieraSecondaryColor = $redux_demo['color-secondary'];		
	$topbarbuttoniconcolor = $redux_demo['topbar-buttonicon-color'];
	$classieraTopbariconTEXTcolor = $redux_demo['topbar-icon-text-color'];
	$homepagesearchinput = $redux_demo['homepage-search-input'];
	$buttonmaincolor = $redux_demo['button-main-color'];
	$body_color = $redux_demo['body-font']['color'];
	
	$heading1color = $redux_demo['heading1-font']['color'];
	$heading2color = $redux_demo['heading2-font']['color'];
	$heading3color = $redux_demo['heading3-font']['color'];
	$heading4color = $redux_demo['heading4-font']['color'];
	$heading5color = $redux_demo['heading5-font']['color'];
	$heading6color = $redux_demo['heading6-font']['color'];
	
	
	$footer_color = $redux_demo['footer-color'];
	$footer_text_color = $redux_demo['fooer-text-color'];
	$footer_heading_color = $redux_demo['fooer-heading-color'];
	
	$footer_bottom_color = $redux_demo['fooer-bottom-color'];
	$footer_bottom_text_color = $redux_demo['fooer-bottom-text-color'];
	$footer_bottom_icon_color = $redux_demo['fooer-bottom-icon-color'];
		
	$measure_system = $redux_demo['measure-system'];

	echo "<style type=\"text/css\">";

	// Main Color
	if(!empty($measure_system)) {

		if($measure_system == "1") {
			
			echo ".range-pin { background: transparent url(";
			echo get_template_directory_uri();
			echo "/images/range-mi.png) no-repeat top left; } ";

		}

	}
		//Body Font Color
		if(!empty($body_color)) {
			
		}
		
		//H1 Color
		if(!empty($heading1color)) {
			echo "{ color: ";		
			echo $heading1color;
			echo " !important; } ";				
		}
		//H2 Color
		if(!empty($heading2color)) {
			echo "{ color: ";		
			echo $heading2color;
			echo "; } ";			
		}
		//H3 Color
		if(!empty($heading3color)) {
			echo "#pricingPlan .priceTable .pricePlan .title h3{ color: ";		
			echo $heading3color;
			echo "; } ";			
		}
		//H4 Color
		if(!empty($heading4color)) {
			echo "#advertisement .tabs-content.listView .listAdv-desc .listAdv-desc-header .icon h4 a, .mainHeading h4, #advertisementv1 .advContentv1 .tabs-content .content .advItemv1 .adv-Text h4 a, .adsCategoryV2 .categoryBox .catHead h4 a{ color: ";		
			echo $heading4color;
			echo "; } ";			
		}
		//H5 Color
		if(!empty($heading5color)) {
			echo "{ color: ";		
			echo $heading5color;
			echo "; } ";			
		}
		//H6 Color
		if(!empty($heading6color)) {
			echo "{ color: ";		
			echo $heading6color;
			echo "; } ";		
		}
		
	// Main Color
	if(!empty($classieraPrimaryColor)) {
		echo ".top-bar .top-bar-section-v1 ul li.active a, .top-bar .top-bar-section-v1 ul li a:hover, .mainSearch .advanceSearch .advSearchBtn a, .range-slider-active-segment, .range-slider.round .range-slider-handle:hover, .mainSearch .advanceSearch .advSeachBar button.submit, .loadMore p a:hover, .parallax a, #adLocations .areaLocation a:hover, #advertisement .tabs-content.listView .listAdv-desc .listAdv-tags .listReadMore a:hover, #advertisement .tabs-content.listView .listAdv-desc .listAdv-tags .listTags a:hover, .button:hover, .uploadBtn:hover, #company p a, .range-slider.round .range-slider-handle, .mainHeading p span, footer .widgetBox .widgetTitle h4::after, footer .widgetBox .widgetContent .tweets p i, footer #back-to-top:hover, footer .footer-bottom .footer-social a:hover, .inner-addon button:hover, #advertisementv1 .advTopBarv1 .tabs .tab-title.active a, .process .processing .icon span.icon-text .small-icon, #big-map .infoBox .close::after, .sidebar .widgetBox .widgetContent .socialShare ul li a:hover i, .share ul.rrssb-buttons li a:hover i, .sidebar .widgetBox .tagcloud a:hover, .authorHead h4::before, .buttonMed:hover, .adHeading i, .aboutMe li i, .socialShare ul li a:hover i,.userAds .ad-description ul li a:hover, .follow-btn .fav-form input[type='submit']:hover, .location .locHeading i, #ad-address span i, .authorProfile .authorDetails i, .topBar ul.topRight li a:hover, .top-bar ul.newAd li a:hover, .topBar ul.social li a:hover, .top-bar .top-bar-section ul li a:hover, .top-bar .top-bar-section ul li.active a, small.error, .follow-btn .browse-favourite a:hover, footer .widgetBox .tagcloud a:hover, span.error, .orbit-container .orbit-prev, .orbit-container .orbit-next, h4.trigger.active{ background: ";
		echo $classieraPrimaryColor;
		echo " !important; } ";
		
		echo ".mainHeading p i, #advertisement .advTopBar .tabb a:hover, .tabs dd.active a, .tabs .tab-title.active a, #advertisement .advTopBar .view a.active i, #advertisement .advTopBar .view a:hover i, footer .widgetBox .widgetContent .tweets p a, .top-bar .top-bar-section #menu-top-menu li ul.dropdown li a:hover, .parallax h3 span, footer .footer-bottom p a, #advertisementv1 .advContentv1 .tabs-content .content .advItemv1 .adv-Text p span.price, #advertisementv1 .advContentv1 .tabs-content .content .advItemv1 .img-hover a:hover, .parallaxV1 h3 span, #pricingPlanV1 .priceTable .pricePlanV1 .price p, #pricingPlanV1 .priceTable .pricePlanV1 ul.description li i, .process .processing .icon span.icon-text i, #faqs .faq .faq-question span.icon i, .post ul li::before, .sidebar .widgetBox .widgetTitle i, .blogPost .blog-post-head h3 a:hover, .sidebar .widgetBox .widgetContent .recentPosts .recentPost .content h5 a:hover, .userAds .ad-description h5 a:hover, .rwd-table td[data-th='Status'], .sidebar .widgetBox .widgetContent .authorAccount ul.authorList li a:hover i, .sidebar .widgetBox .widgetContent .authorAccount ul.authorList li a:hover, .sidebar .widgetBox .widgetContent .authorAccount ul.authorList li a:hover span, .radio p input[type='radio']:checked + label::before, .pageHeading h3 > a:hover, .pageHeading h3 span a:hover, #advertisement .tabs-content.listView .listAdv-desc .listAdv-desc-header .icon h4 a:hover, footer #back-to-top, #premiumAdv .customNavigation .navText a:hover, #premiumAdv .customNavigation .navText a:hover i, .adsCategoryV2 .categoryBox .catHead h4 a:hover, .plans-inner, ul.plans-inner-i li i, a.resetPass:hover, a.termsA:hover, p.noPlan a:hover, #result .message a, .loginContent .loginLogo p a, .textContent i, .blogPost .blog-post-head p strong, ul.aboutMe li a:hover, #ad-address a:hover, .adDetail a:hover, h4.trigger:hover, .authorUrl p a:hover, .addComment p a:hover, .pageHeading a:hover, #advertisement article a:hover, a.rsswidget:hover{ color: ";
		echo $classieraPrimaryColor;
		echo " !important; } ";
		
		echo " { background:rgba( ";
		echo hex2rgb($classieraPrimaryColor);
		echo ",.9 )} ";
		
		echo "footer .widgetBox .widgetContent .premiumAds .premiumAdvs .Advimg .hover a, .sidebar .widgetBox .widgetContent .premiumAds .premiumAdvs .Advimg .hover a{ background:rgba( ";
		echo hex2rgb($classieraPrimaryColor);
		echo ",.5 )} ";
		
		echo "{ background-color: ";		
		echo $classieraPrimaryColor;
		echo " !important; } ";
		
		echo ".mainSearch .advanceSearch .advSeachBar, #adLocations .areaLocation a:hover, .top-bar .top-bar-section-v1 ul.dropdown li:nth-of-type(3), #advertisementv1 .advTopBarv1 .tabs .tab-title.active a, #pricingPlanV1 .priceTable.active, .post blockquote, .pageHeading, .sidebar .widgetBox > h4::before, .sidebar .widgetBox .widgetTitle::before, .userComments .loguserComment .btn:hover, .follow-btn .fav-form input[type='submit']:hover, .top-bar ul.newAd li a, #pricingPlan .priceTable:hover .plans-innerHover{ border-color:";
		echo $classieraPrimaryColor;
		echo " !important; } ";
		
		echo "#pricingPlanV1 .popular, #pricingPlan .priceTable .pricePlan, .mainSearch .advanceSearch .advSeachBar .range .range-slider .range-slider-handle .range-slider-out, .top-bar .top-bar-section #menu-top-menu li ul.dropdown li:nth-of-type(3), .stickInner{ border-top-color:";
		echo $classieraPrimaryColor;
		echo "; } ";
		
		echo ".top-bar .top-bar-section #menu-top-menu li ul.dropdown li:nth-of-type(3){ border-top-color:";
		echo $classieraPrimaryColor;
		echo " !important; } ";
	
	}
	//Top Bar Icon And Buttons Color
	if(!empty($topbarbuttoniconcolor)) {
		echo ".topBar ul.social li a, .topBar ul.topRight li a{ background: ";
		echo $topbarbuttoniconcolor;
		echo " !important; } ";
	}
	//Top Bar Icon And Buttons Text Color
	if(!empty($classieraTopbariconTEXTcolor)) {
		echo ".topBar ul.social li a i, .topBar ul.topRight li a, .topBar ul.topRight li a i{ color: ";
		echo $classieraTopbariconTEXTcolor;
		echo " !important; } ";
		
		echo ".topBar ul.topRight li a i{ border-color: ";
		echo $classieraTopbariconTEXTcolor;
		echo " !important; } ";
	}
	//Secondary Color
	if(!empty($classieraSecondaryColor)) {
		echo ".topBar, .mainSearch .advanceSearch .advSeachBar{ background: ";
		echo $classieraSecondaryColor;
		echo " !important; } ";
	}
	
	//HomePage V1 Search Input BG
	if(!empty($homepagesearchinput)) {		
		echo ".mainSearch .advanceSearch .advSeachBar input, .mainSearch .advanceSearch .advSeachBar select{ background: ";
		echo $homepagesearchinput;
		echo " !important; } ";
		
		echo ".mainSearch .advanceSearch .advSeachBar input, .mainSearch .advanceSearch .advSeachBar select{ border-top-color: ";
		echo $homepagesearchinput;
		echo " !important; } ";
		
		echo ".mainSearch .advanceSearch .advSeachBar input, .mainSearch .advanceSearch .advSeachBar select{ border-right-color: ";
		echo $homepagesearchinput;
		echo " !important; } ";
		
		echo ".mainSearch .advanceSearch .advSeachBar input, .mainSearch .advanceSearch .advSeachBar select{ border-left-color: ";
		echo $homepagesearchinput;
		echo " !important; } ";
	}
	
	// footer Color
	if(!empty($footer_color)) {
		echo "footer .footer-content{ background-color: ";
		echo $footer_color;
		echo "; } ";
	
	}
	//Footer Text Color
	if(!empty($footer_text_color)) {
		echo "footer .textwidget, footer .widgetBox .widgetContent p, footer .widgetBox .widgetContent .recentPosts .recentPost .content h5 a, footer .widgetBox .widgetContent .recentPosts .recentPost .content p{ color: ";
		echo $footer_text_color;
		echo "; } ";
	
	}
	//Footer Heading Color
	if(!empty($footer_heading_color)) {
		echo "footer .widgetBox .widgetTitle h4{ color: ";
		echo $footer_heading_color;
		echo "; } ";
	
	}
	// Footer Bottom Color
	if(!empty($footer_bottom_color)) {
		echo "footer .footer-bottom{ background-color: ";
		echo $footer_bottom_color;
		echo "; } ";
	
	}
	// Footer Bottom Text Color
	if(!empty($footer_bottom_text_color)) {
		echo "footer .footer-bottom p, footer .footer-bottom .footer-social a i{ color: ";
		echo $footer_bottom_text_color;
		echo "; } ";
	
	}
	// Footer Bottom Icon Color
	if(!empty($footer_bottom_icon_color)) {
		echo "footer .footer-bottom .footer-social a{ background-color: ";
		echo $footer_bottom_icon_color;
		echo "; } ";
	
	}
	// Button Color
	if(!empty($buttonmaincolor)) {
			
		echo ".loadMore p a, #advertisement .tabs-content.listView .listAdv-desc .listAdv-tags .listReadMore a, .button, .uploadBtn{ background: ";
		echo $buttonmaincolor;
		echo "!important; } ";

		echo "  { color: ";
		echo $buttonmaincolor;
		echo "; } ";

	}
	// Main Color
	if(!empty($classieraMainColor)) {
			
		echo " { color: ";
		echo $classieraMainColor;
		echo "; } ";

		echo " { background-color: ";
		echo $classieraMainColor;
		echo "; } ";	

		echo "";
		echo $classieraMainColor;
		echo "; } ";

	}
	if ( is_page_template( 'template-homepage-v2.php' ) || is_page_template( 'template-homepage-v3.php' ) || is_page_template( 'template-homepage-v4.php' ) ) {
		
		echo ".footer-content{ padding-top: ";
		echo "100px";
		echo "!important; } ";
		
		echo ".footer-content{ padding-bottom: ";
		echo "20px";
		echo "!important; } ";
	}
	if(is_archive()){
		
		echo ".pagination{ border: ";
		echo "none";
		echo "!important; } ";		
		
	}
	global $redux_demo;
	$turnonsearchcat = $redux_demo['turnonsearchcat'];
	$turnonsearchloc = $redux_demo['turnonsearchloc'];
	$turnonsearchrange = $redux_demo['turnonsearchrange'];
	
	/* If Category Turn On*/
	if($turnonsearchcat == 1 && $turnonsearchloc != 1 && $turnonsearchrange != 1){
		echo ".mainSearch .advanceSearch .advSeachBar input{ width:";
		echo "68%";
		echo "!important; } ";
	}
	/* If Location Turn On*/
	if($turnonsearchloc == 1 && $turnonsearchcat != 1 && $turnonsearchrange != 1){
		echo ".mainSearch .advanceSearch .advSeachBar input{ width:";
		echo "68%";
		echo "!important; } ";
	}
	/* If Range Turn On*/
	if($turnonsearchrange == 1 && $turnonsearchloc != 1 && $turnonsearchcat != 1){
		echo ".mainSearch .advanceSearch .advSeachBar input{ width:";
		echo "56%";
		echo "!important; } ";
	}
	if($turnonsearchcat != 1 && $turnonsearchloc != 1 && $turnonsearchrange != 1){
		echo ".mainSearch .advanceSearch .advSeachBar input{ width:";
		echo "85%";
		echo "!important; } ";
	}
	/*Image Banner Settings*/
	?>
	section.customBg{
		<?php if($redux_demo['classiera_header_bg']){ ?>
		background-color:<?php echo $redux_demo['classiera_header_bg']['background-color']; ?>;
		background-image:url("<?php echo $redux_demo['classiera_header_bg']['background-image']; ?>");
		background-repeat:<?php echo $redux_demo['classiera_header_bg']['background-repeat']; ?>;
		background-position:<?php echo $redux_demo['classiera_header_bg']['background-position']; ?>;
		background-size:<?php echo $redux_demo['classiera_header_bg']['background-size']; ?>;
		background-attachment:<?php $redux_demo['classiera_header_bg']['background-attachment']; ?>;
		<?php } ?>
	}
	.customBg .customBgText h1{
		color:<?php echo $redux_demo['classiera_banner_heading_typography']['color']; ?>;
		font-size:<?php echo $redux_demo['classiera_banner_heading_typography']['font-size']; ?>;
		font-family:<?php echo $redux_demo['classiera_banner_heading_typography']['font-family']; ?>;
		font-weight:<?php echo $redux_demo['classiera_banner_heading_typography']['font-weight']; ?>;
		line-height:<?php echo $redux_demo['classiera_banner_heading_typography']['line-height']; ?>;
		text-align:<?php echo $redux_demo['classiera_banner_heading_typography']['text-align']; ?>;
		letter-spacing:<?php echo $redux_demo['classiera_banner_heading_typography']['letter-spacing']; ?>;
	}
	.customBg .customBgText p{
		color:<?php echo $redux_demo['classiera_banner_desc_typography']['color']; ?>;
		font-size:<?php echo $redux_demo['classiera_banner_desc_typography']['font-size']; ?>;
		font-family:<?php echo $redux_demo['classiera_banner_desc_typography']['font-family']; ?>;
		font-weight:<?php echo $redux_demo['classiera_banner_desc_typography']['font-weight']; ?>;
		line-height:<?php echo $redux_demo['classiera_banner_desc_typography']['line-height']; ?>;
		text-align:<?php echo $redux_demo['classiera_banner_desc_typography']['text-align']; ?>;
		letter-spacing:<?php echo $redux_demo['classiera_banner_desc_typography']['letter-spacing']; ?>;
	}
	<?php
	/*Image Banner Settings*/

	echo "</style>";

}