<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package newscope
 */

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<?php
		if( true === get_theme_mod( 'single_image', true ) ){
			if ( get_post_format() === 'gallery' ) {
				get_template_part( 'template-parts/post/post-format-gallery' );
			} else if ( get_post_format() === 'video' ) {
				get_template_part( 'template-parts/post/post-format-video' );
			} else if ( get_post_format() === 'audio' ) {
				get_template_part( 'template-parts/post/post-format-audio' );
			} else {
				get_template_part( 'template-parts/post/post-format-others' );
			}
		}
	?>
	<div class="post-content-wrapper">
		<?php if ( 'post' === get_post_type() ) : ?>
			<div class="post-meta">
				<ul>
					<?php if( true === get_theme_mod( 'single_author', true ) ) : ?>
						<li><?php newscope_posted_by(); ?></li>
					<?php endif; ?>

					<?php if( true === get_theme_mod( 'single_date', true ) ) : ?>
					<li><?php newscope_posted_on(); ?></li>
					<?php endif; ?>
					

					<?php if ( get_comments_number() != 0 && true === get_theme_mod( 'single_comment', true ) ) : ?>
						<li class="comment-number"><?php newscope_comment_count(); ?></li>
					<?php endif; ?>

					<?php if( true === get_theme_mod( 'single_cats', true ) ) : ?>
					<li><?php newscope_post_categories(); ?></li>
					<?php endif; ?>

				</ul>
			</div>
		<?php endif; ?>

		<?php if( true === get_theme_mod( 'single_title', true )  ) : 
			$newscope_title_tag = get_theme_mod( 'single_title_tag', 'h2' );
		?>
			<header class="entry-header">
				<<?php echo esc_attr(esc_attr( $newscope_title_tag )); ?> class="entry-title single post-title"><?php the_title(); ?></<?php echo esc_attr( $newscope_title_tag ); ?>>
			</header><!-- .entry-header -->
		<?php endif; ?>

		<div class="entry-content">
			<?php
			the_content(
				sprintf(
					wp_kses(
						/* translators: %s: Name of current post. Only visible to screen readers */
						__( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'newscope' ),
						array(
							'span' => array(
								'class' => array(),
							),
						)
					),
					wp_kses_post( get_the_title() )
				)
			);

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

		<footer class="entry-footer">
			<div class="post-footer">
				<?php 
					if( true === get_theme_mod( 'single_tags', true ) ){
						newscope_post_tags(); 
					}
					if( true === get_theme_mod( 'single_share', true ) ){
						newscope_post_share();
					}
				?>
			</div>
		</footer><!-- .entry-footer -->
	</div>
</article><!-- #post-<?php the_ID(); ?> -->
