<?php
/**
 * Creation Theme Customizer.
 *
 * @package Creation
 */

/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function creation_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';
}
add_action( 'customize_register', 'creation_customize_register' );


function creation_custom_header_and_background() {

	add_theme_support( 'custom-header', apply_filters( 'creation_custom_header_args', array(
		'default-text-color'     => '#000000',
		'width'                  => 200,
		'height'                 => 61,
		'flex-height'            => true,
		'wp-head-callback'       => 'creation_header_style',
	) ) );
}
add_action( 'after_setup_theme', 'creation_custom_header_and_background' );

if ( ! function_exists( 'creation_header_style' ) ) :
function creation_header_style() {
	// If the header text option is untouched, let's bail.
	if ( display_header_text() ) {
		return;
	}

	// If the header text has been hidden.
	?>
	<style type="text/css" id="">
	
	.site-branding {
			margin: 0 auto 0 0;
		}

		.site-branding .site-title,
		.site-description {
			clip: rect(1px, 1px, 1px, 1px);
			position: absolute;
		}
	</style>
	<?php
}
endif; 


/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function creation_customize_preview_js() {
	wp_enqueue_script( 'creation_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
}
add_action( 'customize_preview_init', 'creation_customize_preview_js' );


