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

$pantry_args = get_query_var( 'pantry_logo_args' );

// Site logo
$pantry_logo_type   = isset( $pantry_args['type'] ) ? $pantry_args['type'] : '';
$pantry_logo_image  = pantry_get_logo_image( $pantry_logo_type );
$pantry_logo_text   = pantry_is_on( pantry_get_theme_option( 'logo_text' ) ) ? get_bloginfo( 'name' ) : '';
$pantry_logo_slogan = get_bloginfo( 'description', 'display' );
if ( ! empty( $pantry_logo_image['logo'] ) || ! empty( $pantry_logo_text ) ) {
	?><a class="sc_layouts_logo" href="<?php echo esc_url( home_url( '/' ) ); ?>">
		<?php
		if ( ! empty( $pantry_logo_image['logo'] ) ) {
			if ( empty( $pantry_logo_type ) && function_exists( 'the_custom_logo' ) && is_numeric($pantry_logo_image['logo']) && (int) $pantry_logo_image['logo'] > 0 ) {
				the_custom_logo();
			} else {
				$pantry_attr = pantry_getimagesize( $pantry_logo_image['logo'] );
				echo '<img src="' . esc_url( $pantry_logo_image['logo'] ) . '"'
						. ( ! empty( $pantry_logo_image['logo_retina'] ) ? ' srcset="' . esc_url( $pantry_logo_image['logo_retina'] ) . ' 2x"' : '' )
						. ' alt="' . esc_attr( $pantry_logo_text ) . '"'
						. ( ! empty( $pantry_attr[3] ) ? ' ' . wp_kses_data( $pantry_attr[3] ) : '' )
						. '>';
			}
		} else {
			pantry_show_layout( pantry_prepare_macros( $pantry_logo_text ), '<span class="logo_text">', '</span>' );
			pantry_show_layout( pantry_prepare_macros( $pantry_logo_slogan ), '<span class="logo_slogan">', '</span>' );
		}
		?>
	</a>
	<?php
}
