<?php
/**
 * The default template for displaying content
 *
 * Used for both singular and index.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Vintuna
 * @since 1.0.0
 */

$vintuna_default = vintuna_get_default_theme_options();
$vintuna_post_layout = esc_html( get_post_meta( get_the_ID(), 'vintuna_post_layout', true ) );
$vintuna_feature_image = esc_html( get_post_meta( get_the_ID(), 'vintuna_ed_feature_image', true ) );
if (empty($vintuna_feature_image)) {
	$vintuna_ed_feature_image = esc_attr(get_theme_mod('ed_post_thumbnail'));
} else{
	$vintuna_ed_feature_image = esc_attr($vintuna_feature_image);
}

if( is_page() ){

	$vintuna_post_layout = get_post_meta(get_the_ID(), 'vintuna_page_layout', true);
	
}
if( $vintuna_post_layout == '' || $vintuna_post_layout == 'global-layout' ){
    
    $vintuna_post_layout = get_theme_mod( 'vintuna_single_post_layout',$vintuna_default['vintuna_single_post_layout'] );

}

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 

	<?php

	if( empty( $vintuna_ed_feature_image ) && $vintuna_post_layout != 'layout-2' ){ ?>

		<div class="post-thumbnail">
			<?php
			$fallback_image_url = vintuna_get_fallback_image_url();
			if ( has_post_thumbnail()) {
				vintuna_post_thumbnail();
			} else {
				echo '<img src="' . esc_url($fallback_image_url) . '" alt="' . esc_attr(get_the_title()) . '" />';
			} ?>
		</div>

	<?php
	}

	if ( is_singular() && $vintuna_post_layout != 'layout-2' ) { ?>

		<header class="entry-header">

			<?php
			if ( 'post' === get_post_type() ) { ?>

				<div class="entry-meta">

					<?php vintuna_entry_footer( $cats = true, $tags = false, $edits = false, $text = false, $icon = false ); ?>

				</div>

			<?php  } ?>

			<h1 class="entry-title entry-title-large">

	            <?php the_title(); ?>

	        </h1>

		</header>

	<?php }

	if ( $vintuna_post_layout != 'layout-2' && is_single() && 'post' === get_post_type() ) { ?>

		<div class="entry-meta">

			<?php
			vintuna_posted_by();
			?>

		</div>

	<?php  } ?>
	





			<div class="entry-content">

				<?php

				the_content( sprintf(
					/* translators: %s: Name of current post. */
					wp_kses( __( 'Continue reading %s <span class="meta-nav">&rarr;</span>', 'vintuna' ), array( 'span' => array( 'class' => array() ) ) ),
					the_title( '<span class="screen-reader-text">"', '"</span>', false )
				) );


                    wp_link_pages(array(
                        'before' => '<div class="page-links">' . esc_html__('Pages:', 'vintuna'),
                        'after' => '</div>',
                    ));
                    ?>

			</div>

			<?php
			if ( is_singular() && 'post' === get_post_type() ) { ?>

				<div class="entry-footer">

                    <div class="entry-meta">
                        <?php vintuna_entry_footer( $cats = false, $tags = true, $edits = true ); ?>
                    </div>

				</div>

			<?php } ?>




</article>