<?php
/**
 * Sample implementation of the Custom Header feature
 *
 * You can add an optional custom header image to header.php like so ...
 *
 * @link https://developer.wordpress.org/themes/functionality/custom-headers/
 *
 * @package Photography Blog
 */

/**
 * Set up the WordPress core custom header feature.
 *
 * @uses photography_blog_header_style()
 */
function photography_blog_custom_header_setup() {
	add_theme_support('custom-header',apply_filters( 'photography_blog_custom_header_args',
			array(
				'default-image'    => get_parent_theme_file_uri( '/images/default-banner.jpg' ),
				'width'         => 1920,
				'height'        => 1080,
				'default-text-color'     => 'fff',
				'flex-height'      => true,
				'wp-head-callback' => 'photography_blog_header_style',
			)
		)
	);

	register_default_headers(
		array(
			'default-image' => array(
				'url'           => '%s/images/default-banner.jpg',
				'thumbnail_url' => '%s/images/default-banner.jpg',
				'description'   => __( 'Default Header Image', 'photography-blog' ),
			),
		)
	);

}
add_action( 'after_setup_theme', 'photography_blog_custom_header_setup' );

if ( ! function_exists( 'photography_blog_header_style' ) ) :
	/**
	 * Styles the header image and text displayed on the blog.
	 *
	 * @see photography_blog_custom_header_setup().
	 */
	function photography_blog_header_style() {
		$header_text_color = get_header_textcolor();

		/*
		 * If no custom options for text are set, let's bail.
		 * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
		 */
		if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
			return;
		}

		// If we get this far, we have custom styles. Let's do this.
		?>
		<style type="text/css">
		<?php
		// Has the text been hidden?
		if ( ! display_header_text() ) :
		?>
			.site-title,
			.site-description {
				position: absolute;
				clip: rect(1px, 1px, 1px, 1px);
                display: none;
                visibility: hidden;
                opacity: 0;
			}
		<?php
			// If the user has set a custom color for the text use that.
			else :
		?>
        .home .slider-enabled .site-title,
        .home .slider-enabled .site-title a,
        .home .slider-enabled .site-description,
        body:not(.home):not(.blog) .site-title,
        body:not(.home):not(.blog) .site-title a,
        body:not(.home):not(.blog) .site-description {
            color: #<?php echo esc_attr( $header_text_color ); ?>;
        }
		<?php endif; ?>
		</style>
		<?php
	}
endif;
