<?php
/**
 * GBS Unique Theme Customizer.
 *
 * @package gbs-unique
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function gbs_unique_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';
	
	$wp_customize->add_section('gbs_unique_footer_section' , array(
			'title' => __( 'Footer Section', 'gbs-unique' ),
			'priority' => null
		));
		
		$wp_customize->add_setting('gbs_unique_footer_copyright', array(
			'sanitize_callback' => 'sanitize_text_field',
			'default' => 'GBS Unique 2016'
		));

		$wp_customize->add_control('gbs_unique_footer_copyright', array(
			'label'    => __( 'Copyright Text', 'gbs-unique' ),
			'section'  => 'gbs_unique_footer_section',
			'setting' => 'gbs_unique_footer_copyright',
			'type' => 'text'
		));

	
}
add_action( 'customize_register', 'gbs_unique_customize_register' );

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function gbs_unique_customize_preview_js() {
	wp_enqueue_script( 'gbs_unique_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'gbs_unique_customize_preview_js' );


function gbs_unique_css(){
	$header_image = get_theme_mod('header_image');
	
	if( @getimagesize($header_image)){
		$header_css = 'url('.$header_image.' );background-position:center;background-repeat:repeat;';
		}else{
			$header_css = "#8D0000;";
			}
		?>

       <style>
		
        .site-header{background: <?php echo $header_css; ?>}

		</style>

	<?php } 

add_action('wp_head','gbs_unique_css');