<?php
/**
 * @package Charity Welfare Funds
 * @subpackage charity-welfare-funds
 * @since charity-welfare-funds 1.0
 * Setup the WordPress core custom header feature.
 * @uses charity_welfare_funds_header_style()
*/

function charity_welfare_funds_custom_header_setup() {

	add_theme_support( 'custom-header', apply_filters( 'charity_welfare_funds_custom_header_args', array(
		'default-text-color'     => 'fff',
		'header-text' 			 =>	false,
		'width'                  => 1400,
		'height'                 => 70,
		'flex-width'         	=> true,
        'flex-height'        	=> true,
		'wp-head-callback'       => 'charity_welfare_funds_header_style',
	) ) );
}

add_action( 'after_setup_theme', 'charity_welfare_funds_custom_header_setup' );

if ( ! function_exists( 'charity_welfare_funds_header_style' ) ) :

add_action( 'wp_enqueue_scripts', 'charity_welfare_funds_header_style' );
function charity_welfare_funds_header_style() {
	if ( get_header_image() ) :
	$charity_welfare_funds_custom_css = "
        .topbar{
			background-image:url('".esc_url(get_header_image())."');
			background-position: center top;
			background-size: cover;
		}";
	   	wp_add_inline_style( 'charity-welfare-funds-basic-style', $charity_welfare_funds_custom_css );
	endif;
}
endif;