<?php
/**
 * Sample implementation of the Custom feature
 *
 *
 * @link https://developer.wordpress.org/themes/functionality/custom-headers/
 * @link https://developer.wordpress.org/themes/customize-api/customizer-objects/
 *
 * @package ilex
 */

function ilex_custom_header_setup() {
	add_theme_support(
		'custom-header',
		apply_filters(
			'ilex_custom_header_args',
			array(
				'default-image'      => '',
				'default-text-color' => '000000',
				'width'              => 1400,
				'height'             => 400,
				'flex-height'        => true,
			)
		)
	);
}
add_action( 'after_setup_theme', 'ilex_custom_header_setup' );


function ilex_customize_register( $wp_customize ) {
/* Link color */
	$wp_customize->add_setting( 'ilex_link_color' , array(
    'default'   => '#ad541c',
    'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_hex_color',
	));

	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ilex_link_color_control', array(
		'label'      => __( 'Link Color', 'ilex' ),
		'section'    => 'colors',
		'settings'   => 'ilex_link_color',
	)));
		/* Link color hover */
	$wp_customize->add_setting( 'ilex_link_color_hover' , array(
    'default'   => '#d50000',
    'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_hex_color',
	));

	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ilex_link_color_hover_control', array(
		'label'      => __( 'Link Color Hover', 'ilex' ),
		'section'    => 'colors',
		'settings'   => 'ilex_link_color_hover',
	)));
		/* Header Color */
	$wp_customize->add_setting( 'ilex_header_color' , array(
    'default'   => '#fff',
    'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_hex_color',
	));

	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ilex_header_color_control', array(
		'label'      => __( 'Header Color', 'ilex' ),
		'section'    => 'colors',
		'settings'   => 'ilex_header_color',
	)));
			/* Footer Color */
	$wp_customize->add_setting( 'ilex_footer_color' , array(
    'default'   => '#fff',
    'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_hex_color',
	));

	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ilex_footer_color_control', array(
		'label'      => __( 'Footer Color', 'ilex' ),
		'section'    => 'colors',
		'settings'   => 'ilex_footer_color',
	)));
				/* Footer bg Color */
	$wp_customize->add_setting( 'ilex_footerbg_color' , array(
    'default'   => '#fff',
    'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_hex_color',
	));

	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ilex_footerbg_color_control', array(
		'label'      => __( 'Footer Bg Color', 'ilex' ),
		'section'    => 'colors',
		'settings'   => 'ilex_footerbg_color',
	)));


	/* primary-menu Color */
	$wp_customize->add_setting( 'ilex_primary_color' , array(
    'default'   => '#ad541c',
    'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_hex_color',
	));

	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ilex_primary_color_control', array(
		'label'      => __( 'Primary menu Color', 'ilex' ),
		'section'    => 'colors',
		'settings'   => 'ilex_primary_color',
	)));
	/* Header title Color */
	$wp_customize->add_setting( 'ilex_title_color' , array(
    'default'   => '#ad541c',
    'transport' => 'refresh',
		'sanitize_callback' => 'sanitize_hex_color',
	));

	$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'ilex_title_color_control', array(
		'label'      => __( 'Title Color', 'ilex' ),
		'section'    => 'colors',
		'settings'   => 'ilex_title_color',
	)));
	$wp_customize->remove_control( 'header_textcolor' );
	
}
add_action( 'customize_register', 'ilex_customize_register' );	

add_action( 'wp_head', 'ilex_customize_css' );
function ilex_customize_css() {
    ?>
         <style type="text/css">	 
			 a { color:<?php echo esc_html(get_theme_mod( 'ilex_link_color', '#ad541c' )); ?>; }
			 a:hover { color:<?php echo esc_html(get_theme_mod( 'ilex_link_color_hover', '#d50000' )); ?>; }
			 span.nav-title{ fill:<?php echo esc_html(get_theme_mod( 'ilex_link_color', '#ad541c' )); ?>; }
			 #site-header, body.is-scrolled #site-header{ background-color:<?php echo esc_html(get_theme_mod( 'ilex_header_color', '#ffffff' )); ?>; }
			 #site-footer { background-color:<?php echo esc_html(get_theme_mod( 'ilex_footerbg_color', '#ffffff' )); ?>; }
			 #site-footer a, #site-footer p { color:<?php echo esc_html(get_theme_mod( 'ilex_footer_color', '#555555' )); ?>; }			 
			 #primary-menu li a{ color:<?php echo esc_html(get_theme_mod( 'ilex_primary_color', '#ad541c' )); ?>; }
			 span.icon path{ fill:<?php echo esc_html(get_theme_mod( 'ilex_primary_color', '#ad541c' )); ?>; }
			 button.menu-toggle{ color:<?php echo esc_html(get_theme_mod( 'ilex_primary_color', '#ad541c' )); ?>; }
			 .icon-hamburger span{ background:<?php echo esc_html(get_theme_mod( 'ilex_primary_color', '#ad541c' )); ?>; }
			 .site-title a, .site-description{ color:<?php echo esc_html(get_theme_mod( 'ilex_title_color', '#555555' )); ?>; }
         </style>
    <?php
}
