<?php
/**
 * prime-construction Theme Customizer
 *
 * @package prime-construction
 */

 // Custom Controls.
require get_template_directory() . '/inc/custom-control/custom-control.php';

// Sanitize callback.
require get_template_directory() . '/inc/customizer/sanitize-callback.php';

// Default
require get_template_directory() . '/inc/customizer/default.php';

// Load customize sanitize.
include get_template_directory() . '/inc/customizer/active-callback.php';


// Theme section.
// require get_template_directory() . '/inc/customizer/theme-section.php';

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function prime_construction_customize_register( $wp_customize ) {
	$wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
	$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';

	if ( isset( $wp_customize->selective_refresh ) ) {
		$wp_customize->selective_refresh->add_partial(
			'blogname',
			array(
				'selector'        => '.site-title a',
				'render_callback' => 'prime_construction_customize_partial_blogname',
			)
		);
		$wp_customize->selective_refresh->add_partial(
			'blogdescription',
			array(
				'selector'        => '.site-description',
				'render_callback' => 'prime_construction_customize_partial_blogdescription',
			)
		);
	}
	// Front Page Link
	require get_template_directory() . '/inc/customizer/home-section.php';

	require get_template_directory() . '/inc/customizer/section-pro.php';

	// Theme Page Link
	require get_template_directory() . '/inc/customizer/theme-options.php';
}
add_action( 'customize_register', 'prime_construction_customize_register' );

/**
 * Render the site title for the selective refresh partial.
 *
 * @return void
 */
function prime_construction_customize_partial_blogname() {
	bloginfo( 'name' );
}

/**
 * Render the site tagline for the selective refresh partial.
 *
 * @return void
 */
function prime_construction_customize_partial_blogdescription() {
	bloginfo( 'description' );
}

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function prime_construction_customize_preview_js() {
	wp_enqueue_script( 'prime_construction-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), prime_construction_S_VERSION, true );
}
add_action( 'customize_preview_init', 'prime_construction_customize_preview_js' );

/**
 *
 */
function prime_construction_customize_backend_scripts() {

	wp_enqueue_style( 'prime-construction-fontawesome-all', get_template_directory_uri() . '/assets/css/all.css' );

	wp_enqueue_style( 'prime-construction-main-css', get_template_directory_uri() . '/src/output.css' );

	wp_enqueue_style( 'prime-construction-admin-customizer-style', get_template_directory_uri() . '/inc/customizer/css/customizer-style.css' );

	wp_enqueue_script( 'prime-construction-admin-customizer', get_template_directory_uri() . '/inc/customizer/js/customizer-script.js', array( 'jquery', 'customize-controls' ), '20151215', true );
	wp_enqueue_script( 'prime-construction-admin-customizer-control', get_template_directory_uri() . '/inc/customizer/js/customize-controls.js', array( 'jquery', 'customize-controls' ), '', true );
}
add_action( 'customize_controls_enqueue_scripts', 'prime_construction_customize_backend_scripts', 10 );

/**
 * Enqueue the stylesheet.
 */
function prime_construction_customizer_stylesheet() {

    wp_register_style( 'prime-construction-admin-css', get_template_directory_uri() . '/inc/customizer/css/customize-controls.css', NULL, NULL, 'all' );
    wp_enqueue_style( 'prime-construction-admin-css' );
}
add_action( 'customize_controls_print_styles', 'prime_construction_customizer_stylesheet' );

///////////////////////////// customize  color 

function prime_construction_customize_css()
{
?>
	<style type="text/css">
		/* ///////////////////////////  color.php /////////////////////////// */
		/* ---------------## Theme Option Section Color Start ##------------- */
	
		#site-navigation{
			background-color:<?php echo esc_html(get_theme_mod('Header_menu_bg_color')); ?>;
		}

		.topheader .icon, .iconshade{
			color: <?php echo esc_html(get_theme_mod('Email_icon_color')); ?>;
		}

		#site-navigation ul li a{
			color: <?php echo esc_html(get_theme_mod('Header_menu_text_color')); ?>;
		}		
		.widget .widget-title, .widget .wp-block-heading, .widget .wp-block-search__label{
			color:<?php echo esc_html(get_theme_mod('Heading_text_color')); ?>;
		}
		.sidebar-div .wp-block-latest-posts__list li a, .sidebar-div .wp-block-archives-list li a, .sidebar-div .wp-block-categories-list li a, .single_sidebar .wp-block-latest-posts__list li a, .single_sidebar .wp-block-archives-list li a, .single_sidebar .wp-block-categories-list li a, .widget_recent_entries li a, .widget_categories li a, #secondary ul li a, .widget_archive p, .widget_archive select {
			color:<?php echo esc_html(get_theme_mod('Text_color')); ?>;
		}
		#primary .widget ul li a::before, #secondary .widget ul li a::before, #primary .widget ol li a::before, #secondary .widget ol li a::before {
			color:<?php echo esc_html(get_theme_mod('side_icon_color')); ?>;
		}
		.widget.widget_search .wp-block-search__inside-wrapper .wp-block-search__button,
		.widget .search-submit{
			background: linear-gradient(135deg, <?php echo esc_html(get_theme_mod('Search_button_Bg_color_first')); ?> 0%, <?php echo esc_html(get_theme_mod('Search_button_Bg_color_second')); ?> 100%);
		}
		.widget.widget_search .wp-block-search__inside-wrapper .wp-block-search__button, .widget .search-submit{
			color:<?php echo esc_html(get_theme_mod('Search_button_text_color')); ?>;
		}
		#site-navigation ul#primary-menu li:last-child {
    		background: linear-gradient(to right, <?php echo esc_html(get_theme_mod('Header_menu_first_bgcolor')); ?> , <?php echo esc_html(get_theme_mod('Header_menu_second_bgcolor')); ?>, <?php echo esc_html(get_theme_mod('Header_menu_third_bgcolor')); ?>);
		}
		.post-details .entry-author a{
			color:<?php echo esc_html(get_theme_mod('Post_authortext_color')); ?>;
		}
		.post-details svg{
			color:<?php echo esc_html(get_theme_mod('Post_authoricon_color')); ?>;
		}
		.post-details .entry-date a{
			color:<?php echo esc_html(get_theme_mod('Post_date_text_color')); ?>;
		}
		.post-details .entry-comments{
			color:<?php echo esc_html(get_theme_mod('Post_comment_text_color')); ?>;
		}
		.mainrow .box .content .maincontent .justcontent h2.page-title a{
			color:<?php echo esc_html(get_theme_mod('Post_heading_text_color')); ?>;
		}
		.maincontent p{
			color:<?php echo esc_html(get_theme_mod('Post_text_color')); ?>;
		}

		/* ---------------## Slider Section Color Start ##------------- */
		#featured-slider .entry-container h4{
			color: <?php echo esc_html(get_theme_mod('slider_title_color')); ?>;
		}

		#featured-slider .entry-container .content{
			color: <?php echo esc_html(get_theme_mod('slider_subtitle_color')); ?>;
		}

		#featured-slider .content a, #featured-slider code,
		.wp-block-buttons .wp-block-button__link, .singlepage #submit{
			background: <?php echo esc_html(get_theme_mod('slider_readmore_color')); ?>;
		}

		#featured-slider .content a, #featured-slider code,
		.wp-block-buttons .wp-block-button__link, .singlepage #submit{
			color: <?php echo esc_html(get_theme_mod('slider_readmoretxt_color')); ?>!important;
		}

		#featured-slider .slick-dots li{
			background: <?php echo esc_html(get_theme_mod('slider_slickdot_color')); ?>;
		}

		#featured-slider .slick-dots li.slick-active{
			background: <?php echo esc_html(get_theme_mod('slider_activeslickdot_color')); ?>;
		}

		#featured-slider .sliderbut1 a{
			color: <?php echo esc_html(get_theme_mod('slider_buttontext1_color')); ?>;
		}
		#featured-slider .sliderbut1{
			background: <?php echo esc_html(get_theme_mod('slider_buttonbg1_color')); ?>;
		}
		#featured-slider .sliderbut2 a{
			color: <?php echo esc_html(get_theme_mod('slider_buttontext2_color')); ?>;
		}
		#featured-slider .sliderbut2{
			background: <?php echo esc_html(get_theme_mod('slider_buttonbg2_color')); ?>;
		}
		/* ---------------## Slider Section Color End ##------------- */

		/* ---------------## What we Offer Section Color Start ##------------- */
		.featured-whatweoffer{
			background: <?php echo esc_html(get_theme_mod('whatweoffer_background_color')); ?>;
		}
		
		.featured-whatweoffer .head-title{
			color: <?php echo esc_html(get_theme_mod('whatweoffer_title_color')); ?>;
		}

		.featured-whatweoffer .head-subtitle{
			color: <?php echo esc_html(get_theme_mod('whatweoffer_subtitle_color')); ?>;
		}
		
		.featured-whatweoffer .title a{
			color: <?php echo esc_html(get_theme_mod('whatweoffer_cardtitle_color')); ?>;
		}
		/* ---------------## What we Offer Section Color End ##------------- */
	</style>
	
<?php
}
add_action('wp_head', 'prime_construction_customize_css');


function total_dynamic_styles(){
    global $post;

    $custom_css = '';

    // Padding top
    $prime_construction_featured_whatweoffer_t_padding = get_theme_mod('prime_construction_featured_whatweoffer_t_padding', '3');
    if ( $prime_construction_featured_whatweoffer_t_padding != '' ) {
        $custom_css .= ' .featured-whatweoffer {';
        $custom_css .= ' padding-top: ' . esc_attr($prime_construction_featured_whatweoffer_t_padding) . 'em;';
        $custom_css .= ' }';
    }

    // Padding bottom
    $prime_construction_featured_whatweoffer_b_padding = get_theme_mod('prime_construction_featured_whatweoffer_b_padding', '3');
    if ( $prime_construction_featured_whatweoffer_b_padding != '' ) {
        $custom_css .= ' .featured-whatweoffer {';
        $custom_css .= ' padding-bottom: ' . esc_attr($prime_construction_featured_whatweoffer_b_padding) . 'em;';
        $custom_css .= ' }';
    }

    return $custom_css;   
}


