<?php
/**
 * Template part for displaying posts
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package pixigo
 */

?>

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

	<?php if ( 'post' === get_post_type() ) : ?>
		<div class="entry-meta">
			<div class="cat-links"><?php pixigo_post_categories(); ?></div>
			<div class="post-meta">
				<?php
				pixigo_posted_on();
				pixigo_comment_count();
				?>
			</div>
		</div><!-- .entry-meta -->
	<?php endif; ?>

	<header class="entry-header">
		<?php
		if ( is_singular() ) :
			the_title( '<h1 class="entry-title">', '</h1>' );
		else :
			the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
		endif;
		?>
	</header><!-- .entry-header -->

	<?php pixigo_post_thumbnail(); ?>

	<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>', 'pixigo' ),
					array(
						'span' => array(
							'class' => array(),
						),
					)
				),
				get_the_title()
			)
		);

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

	<footer class="entry-footer">

		<?php if ( ! get_theme_mod( 'post_hide_tag_display', 0 ) ) : ?>
			<div class="tags-links"><?php the_tags( '#' ); ?></div>
		<?php endif; ?>

		<?php pixigo_edit_post_link(); ?>

	</footer><!-- .entry-footer -->
</article><!-- #post-<?php the_ID(); ?> -->

<?php
if ( is_singular() ) :

	if ( ! get_theme_mod( 'post_hide_authorbox', 0 ) ) {
		get_template_part( 'template-parts/components/authorbox' );
	}

	if ( ! get_theme_mod( 'post_hide_related_posts', 0 ) ) {
		get_template_part( 'template-parts/components/related-posts' );
	}

	// If comments are open or we have at least one comment, load up the comment template.
	if ( comments_open() || get_comments_number() ) :
		comments_template();
	endif;
endif;
