<?php
/**
 * Sample implementation of the Custom Header feature
 * http://codex.wordpress.org/Custom_Headers
 *
 * You can add an optional custom header image to header.php like so ...

	<?php $header_image = get_header_image();
	if ( ! empty( $header_image ) ) { ?>
		<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
			<img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
		</a>
	<?php } // if ( ! empty( $header_image ) ) ?>

 *
 * @package Structure
 */

/**
 * Setup the WordPress core custom header feature.
 *
 * @package Structure
 */
function structure_custom_header_setup() {
	add_theme_support( 'custom-header', apply_filters( 'structure_custom_header_args', array(
		'default-text-color'     => '999',
		'width'                  => 960,
		'height'                 => 120,
		'flex-height'            => true,
		'wp-head-callback'       => 'header_style',
		'admin-head-callback'    => 'structure_admin_header_style',
	) ) );
}
add_action( 'after_setup_theme', 'structure_custom_header_setup' );

/**
 * Styles the header image displayed on the Appearance > Header admin panel.
 *
 * @see structure_custom_header_setup().
 */
function structure_admin_header_style() {
	?>
	<style type="text/css">
		#headimg {
			height: <?php echo get_custom_header()->height; ?>px;
			width: <?php echo get_custom_header()->width; ?>px;
			<?php if ( st_option( 'dark_scheme' ) ) : ?>
			background: #000;
			<?php else : ?>
			background: #fff;
			<?php endif; ?>
			margin-bottom: 1em;
			overflow: hidden;
		}
		#headimg h1 {
			padding: 47px 10px 0 10px;
		}
		#headimg h1 a {
			color: #<?php header_textcolor(); ?>;
			font: 36px/36px Georgia, "Times New Roman", Times, serif;
			font-style: italic;
			font-weight: bold;
			text-decoration: none;
		}
		#headimg #desc {
			display: none;
		}
	</style>
	<?php
}

/**
 * Styles the header image and text displayed on the blog
 *
 * @see structure_custom_header_setup().
 */
function header_style() { ?>
	<style type="text/css">
		<?php if ( '' != get_header_image() ) : ?>
		#header h1 a, #header h1 a:visited {
			background: url(<?php header_image(); ?>) no-repeat top;
		}
		<?php endif; ?>

		<?php if ( 'blank' != get_header_textcolor() ) : ?>
		#header h1 a, #header h1 a:visited {
			color: #<?php header_textcolor(); ?> !important;
		}
		<?php else : /* hide header text */ ?>
		#header h1 a span {
			text-indent: -1000em !important;
		}
		<?php endif; ?>
	</style>
	<?php
}