<?php
/**
 * Template For Header site identity
 * @since 1.0
 * @package RoyalNews
 */?>

<?php $bg_image = royalnews_value( 'header-bg-image' );
if( '' != $bg_image ){
    $style = 'style="background-image:url('. $bg_image['url'] .')"';
}else{
    $style = '';
}?>
<div class="royalnews-header-wrap" <?php echo $style; ?>>
    <div class="container">
        <div class="royalnews-upper-header">
            <div class="royalnews-site-identity-wrapper">
                <div class="royalnews-site-identity-inner">
                    <?php the_custom_logo(); ?>
                    <div class="<?php echo !display_header_text() ? 'screen-reader-text' : ''; ?>">
                        <?php if ( is_front_page() ) :
                            ?>
                            <h1 class="royalnews-site-title">
                                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
                                    <?php bloginfo( 'name' ); ?>                                    
                                </a>
                            </h1>
                        <?php else : ?>
                            <p class="royalnews-site-title">
                                <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
                                    <?php bloginfo( 'name' ); ?>                                    
                                </a>
                            </p>
                        <?php endif;
                        
                        $description = get_bloginfo( 'description', 'display' );
                        if ( $description || is_customize_preview() ) :
                            ?>
                            <p class="royalnews-site-description">
                                <?php echo esc_html( $description ); /* WPCS: xss ok. */ ?>                             
                            </p>
                        <?php endif; ?>
                    </div>
                </div>
                <?php $time = royalnews_value( 'enable-date-tile' );
                if( ''!= $time ){?>
                    <div class="royalnews-time-wrapper">
                        <div class="royalnews-time-inner">
                            <time datetime="<?php echo esc_attr( date( DATE_W3C ) ); ?>">
                                <?php echo esc_html( date( get_option( 'date_format' ) ) ); ?>
                            </time>
                        </div>
                        <div 
                            class="royalnews-digital-clock-wrapper"
                            data-timezone="<?php echo _ROYALNEWS_TIMEZONES[ royalnews_value( 'timezone-list' ) ]; ?>"
                            data-timezone-type="<?php echo royalnews_value( 'time-format' ); ?>"
                        >
                            <span class="royalnews-time"></span>
                        </div> 
                    </div>            
                <?php }?> 
            </div>
            <?php $ads_image = royalnews_value( 'advertisement-image' );
            if( '' != $ads_image ): ?>
                <div class="royalnews-advertisement-wrap">
                    <a href="<?php echo esc_url( royalnews_value( 'advertisement-url' ) ) ?>">                            
                        <img src="<?php echo esc_url( $ads_image[ 'url' ] ); ?>">
                    </a>
                </div>
            <?php endif; ?>
        </div> 
    </div>    
</div>