<?php
/**
 * express-movers Theme Customizer
 *
 * @package express-movers
 */

 // 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 express_movers_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' => 'express_movers_customize_partial_blogname',
			)
		);
		$wp_customize->selective_refresh->add_partial(
			'blogdescription',
			array(
				'selector'        => '.site-description',
				'render_callback' => 'express_movers_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', 'express_movers_customize_register' );

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

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

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

/**
 *
 */
function express_movers_customize_backend_scripts() {

	wp_enqueue_style( 'express-movers-fontawesome-all', get_template_directory_uri() . '/assets/css/all.css' );

	wp_enqueue_style( 'express-movers-main-css', get_template_directory_uri() . '/assets/css/output.css' );

	wp_enqueue_style( 'express-movers-admin-customizer-style', get_template_directory_uri() . '/inc/customizer/css/customizer-style.css' );

	// Enqueue main customizer JS
	wp_enqueue_script(
		'express-movers-admin-customizer',
		get_template_directory_uri() . '/inc/customizer/js/customizer-script.js',
		array( 'jquery', 'customize-controls' ),
		'20151215',
		true
	);

	// Enqueue the controls script
	wp_enqueue_script(
		'express-movers-admin-customizer-control',
		get_template_directory_uri() . '/inc/customizer/js/customize-controls.js',
		array( 'jquery', 'customize-controls' ),
		'1.0',
		true
	);

	// Fix: Localize the customizer params for use in JS
	wp_localize_script(
		'express-movers-admin-customizer-control',
		'express_movers_customizer_params',
		array(
			'ajaxurl' => admin_url( 'admin-ajax.php' ),
		)
	);
}
add_action( 'customize_controls_enqueue_scripts', 'express_movers_customize_backend_scripts', 10 );

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

    wp_register_style( 'express-movers-admin-css', get_template_directory_uri() . '/inc/customizer/css/customize-controls.css', NULL, NULL, 'all' );
    wp_enqueue_style( 'express-movers-admin-css' );
}
add_action( 'customize_controls_print_styles', 'express_movers_customizer_stylesheet' );

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


function express_movers_customize_css() {
    $custom_css = "
        #site-navigation .nav-sitemenu {
            background-color: " . esc_html(get_theme_mod('menu_bg_color')) . ";
        }
        #site-navigation ul li a{
            color: " . esc_html(get_theme_mod('menu_text_color')) . ";
        }    
        #section-header .header-col-divs a{
            background-color: " . esc_html(get_theme_mod('button_bg_color')) . ";
        }
        #section-header .header-col-divs a{
            color: " . esc_html(get_theme_mod('button_text_color')) . ";
        }
        .slider-inner-mainbox .slider-socialicon .socialicon {
            color: " . esc_html(get_theme_mod('social_icon_color')) . ";
        }
        #featured-slider .entry-container h4 {
            color: " . esc_html(get_theme_mod('slider_title_color')) . ";
        }
        #featured-slider .entry-container .content {
            color: " . esc_html(get_theme_mod('slider_subtitle_color')) . ";
        }
        #section-header .topheader {
           background-color: " . esc_html(get_theme_mod('top_header_bg_color')) . ";
        }
        #section-header .topheader-item a,
        #section-header .topheader-item i,
        #section-header .topheader-announcement-text {
            color: " . esc_html(get_theme_mod('top_header_info_text_color')) . ";
        }
        #section-header .topheader-announcement-icon,
        #section-header .topheader-announcement-arrow {
            color: " . esc_html(get_theme_mod('top_header_accent_color', '#d15b47')) . ";
        }
        #section-header .topheader-social-btn {
            background-color: " . esc_html(get_theme_mod('top_header_icon_bg_color')) . ";
        }
        #section-header .topheader-social-btn i {
            color: " . esc_html(get_theme_mod('top_header_info_text_color')) . ";
        }
        #section-header .topheader-phone svg{
            color: " . esc_html(get_theme_mod('top_header_callicon_color')) . ";
        }
        #section-header .topheader-email svg {
            color: " . esc_html(get_theme_mod('top_header_emailicon_color')) . ";
        }
        .wp-block-search__button{
            background-color: " . esc_html(get_theme_mod('sidebar_search_btn_bg_color')) . " !important;
        }    
        #featured-slider .content a,
        #featured-slider code,
        .wp-block-buttons .wp-block-button__link,
        .singlepage #submit {
            background: " . esc_html(get_theme_mod('slider_readmore_color')) . ";
            color: " . esc_html(get_theme_mod('slider_readmoretxt_color')) . " !important;
        }
        #featured-slider .slick-dots li {
            background: " . esc_html(get_theme_mod('slider_slickdot_color')) . ";
        }
        #featured-slider .slick-dots li.slick-active {
            background: " . esc_html(get_theme_mod('slider_activeslickdot_color')) . ";
        }
        #featured-slider .sliderbut1 a {
            color: " . esc_html(get_theme_mod('slider_buttontext1_color')) . ";
        }
        #featured-slider .sliderbut1 {
            background: " . esc_html(get_theme_mod('slider_buttonbg1_color')) . ";
        }
        #featured-slider .sliderbut2 a {
            color: " . esc_html(get_theme_mod('slider_buttontext2_color')) . ";
        }
        #featured-slider .sliderbut2 {
            background: " . esc_html(get_theme_mod('slider_buttonbg2_color')) . ";
        }
        .featured-whatweoffer {
            background: " . esc_html(get_theme_mod('whatweoffer_background_color')) . ";
        }
        .featured-whatweoffer .head-title {
            color: " . esc_html(get_theme_mod('whatweoffer_title_color')) . ";
        }
        .featured-whatweoffer .head-subtitle {
            color: " . esc_html(get_theme_mod('whatweoffer_subtitle_color')) . ";
        }
        .featured-whatweoffer .title a {
            color: " . esc_html(get_theme_mod('whatweoffer_cardtitle_color')) . ";
        }
        #colophon.footer-modern-wrap {
            background-color: " . esc_html( get_theme_mod( 'express_movers_footer_bg_color', '#0a1f44' ) ) . ";
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__about,
        #colophon.footer-modern-wrap .footer-modern__stat-label {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__brand-title {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__col-title {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__brand-icon,
        #colophon.footer-modern-wrap .footer-modern__stat-icon,
        #colophon.footer-modern-wrap .footer-modern__contact-row i {
            color: " . esc_html( get_theme_mod( 'express_movers_footer_accent_color', '#f97316' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__col-title::after {
            background-color: " . esc_html( get_theme_mod( 'express_movers_footer_accent_color', '#f97316' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__stat {
            background-color: " . esc_html( get_theme_mod( 'express_movers_footer_surface_color', '#132a45' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__stat-num {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__social-btn {
            background-color: " . esc_html( get_theme_mod( 'express_movers_footer_surface_color', '#132a45' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__social-btn i {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__links a {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__contact-row,
        #colophon.footer-modern-wrap .footer-modern__contact-row span {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__cta {
            background-color: " . esc_html( get_theme_mod( 'express_movers_footer_accent_color', '#f97316' ) ) . ";
            color: #ffffff !important;
        }
        #colophon.footer-modern-wrap .footer-modern__cta i {
            color: #ffffff !important;
        }
        #colophon.footer-modern-wrap .footer-modern__subbar {
            background-color: " . esc_html( get_theme_mod( 'express_movers_footer_subbar_bg_color', '#060d18' ) ) . ";
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . ";
        }
        #colophon.footer-modern-wrap .footer-modern__subbar a {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . "; opacity: 0.85;
        }
        #colophon.footer-modern-wrap .footer-modern__copyright {
            color: " . esc_html( get_theme_mod( 'footer_icon_color', '#ffffff' ) ) . "; opacity: 0.75;
        }
    ";

    // Ensure the main stylesheet is enqueued first
    wp_enqueue_style('express-movers-style', get_stylesheet_uri());

    // Add inline CSS to it
    wp_add_inline_style('express-movers-style', $custom_css);
}
add_action('wp_enqueue_scripts', 'express_movers_customize_css');
