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

$newsnation_default = newsnation_get_default_theme_options();
$newsnation_post_layout = esc_html( get_post_meta( get_the_ID(), 'newsnation_post_layout', true ) );
$newsnation_feature_image = esc_html( get_post_meta( get_the_ID(), 'newsnation_ed_feature_image', true ) );
if (empty($newsnation_feature_image)) {
	$newsnation_ed_feature_image = esc_attr(get_theme_mod('ed_post_thumbnail'));
} else{
	$newsnation_ed_feature_image = esc_attr($newsnation_feature_image);
}

if( is_page() ){

	$newsnation_post_layout = get_post_meta(get_the_ID(), 'newsnation_page_layout', true);
	
}
if( $newsnation_post_layout == '' || $newsnation_post_layout == 'global-layout' ){
    
    $newsnation_post_layout = get_theme_mod( 'newsnation_single_post_layout',$newsnation_default['newsnation_single_post_layout'] );

}

?>

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

	<?php

	if( empty( $newsnation_ed_feature_image ) && $newsnation_post_layout != 'layout-2' ){ ?>

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

	<?php
	}

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

		<header class="entry-header">

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

				<div class="entry-meta">

					<?php newsnation_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 ( $newsnation_post_layout != 'layout-2' && is_single() && 'post' === get_post_type() ) { ?>

		<div class="entry-meta">

			<?php
			newsnation_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>', 'newsnation' ), 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:', 'newsnation'),
                        'after' => '</div>',
                    ));
                    ?>

			</div>

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

				<div class="entry-footer">

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

				</div>

			<?php } ?>




</article>