<?php
/**
 * The template to display the logo or the site name and the slogan in the Header
 *
 * @package HYGIA
 * @since HYGIA 1.0
 */

$hygia_args = get_query_var( 'hygia_logo_args' );

// Site logo
$hygia_logo_type   = isset( $hygia_args['type'] ) ? $hygia_args['type'] : '';
$hygia_logo_image  = hygia_get_logo_image( $hygia_logo_type );
$hygia_logo_text   = hygia_is_on( hygia_get_theme_option( 'logo_text' ) ) ? get_bloginfo( 'name' ) : '';
$hygia_logo_slogan = get_bloginfo( 'description', 'display' );
if ( ! empty( $hygia_logo_image['logo'] ) || ! empty( $hygia_logo_text ) ) {
	?><a class="sc_layouts_logo" href="<?php echo esc_url( home_url( '/' ) ); ?>">
		<?php
		if ( ! empty( $hygia_logo_image['logo'] ) ) {
			if ( empty( $hygia_logo_type ) && function_exists( 'the_custom_logo' ) && is_numeric($hygia_logo_image['logo']) && (int) $hygia_logo_image['logo'] > 0 ) {
				the_custom_logo();
			} else {
				$hygia_attr = hygia_getimagesize( $hygia_logo_image['logo'] );
				echo '<img src="' . esc_url( $hygia_logo_image['logo'] ) . '"'
						. ( ! empty( $hygia_logo_image['logo_retina'] ) ? ' srcset="' . esc_url( $hygia_logo_image['logo_retina'] ) . ' 2x"' : '' )
						. ' alt="' . esc_attr( $hygia_logo_text ) . '"'
						. ( ! empty( $hygia_attr[3] ) ? ' ' . wp_kses_data( $hygia_attr[3] ) : '' )
						. '>';
			}
		} else {
			hygia_show_layout( hygia_prepare_macros( $hygia_logo_text ), '<span class="logo_text">', '</span>' );
			hygia_show_layout( hygia_prepare_macros( $hygia_logo_slogan ), '<span class="logo_slogan">', '</span>' );
		}
		?>
	</a>
	<?php
}
