<?php
/**
 * The template for displaying Archive pages.
 *
 * @package shrk
 */

get_header(); ?>

<div <?php echo apply_filters( 'shrk-page-cover-atts', 'page-cover' ); ?> >
	<header class="page-header">
		<h1 class="page-title">
			<?php
				if ( is_category() ) :
					single_cat_title();

				elseif ( is_tag() ) :
					echo esc_html__( 'Tag: ', 'ux-shop' ) . '<span>' . single_tag_title('', false) . '</span>';
				elseif ( is_author() && have_posts() ) :
					/* Queue the first post, that way we know
					 * what author we're dealing with (if that is the case).
					*/
					the_post();
					printf( esc_html__( 'Author: %s', 'ux-shop' ), '<span class="vcard">' . get_the_author() . '</span>' );
					/* Since we called the_post() above, we need to
					 * rewind the loop back to the beginning that way
					 * we can run the loop properly, in full.
					 */
					rewind_posts();

				elseif ( is_day() ) :
					printf( esc_html__( 'Day: %s', 'ux-shop' ), '<span>' . get_the_date() . '</span>' );

				elseif ( is_month() ) :
					printf( esc_html__( 'Month: %s', 'ux-shop' ), '<span>' . get_the_date( 'F Y' ) . '</span>' );

				elseif ( is_year() ) :
					printf( esc_html__( 'Year: %s', 'ux-shop' ), '<span>' . get_the_date( 'Y' ) . '</span>' );

				elseif ( is_tax( 'post_format', 'post-format-aside' ) ) :
					esc_html_e( 'Asides', 'ux-shop' );

				elseif ( is_tax( 'post_format', 'post-format-image' ) ) :
					esc_html_e( 'Images', 'ux-shop');

				elseif ( is_tax( 'post_format', 'post-format-video' ) ) :
					esc_html_e( 'Videos', 'ux-shop' );

				elseif ( is_tax( 'post_format', 'post-format-quote' ) ) :
					esc_html_e( 'Quotes', 'ux-shop' );

				elseif ( is_tax( 'post_format', 'post-format-link' ) ) :
					esc_html_e( 'Links', 'ux-shop' );

				else :
					esc_html_e( 'Archives', 'ux-shop' );

				endif;
			?>
		</h1>
		<?php
			// Show an optional term description.
			$term_description = term_description();
			if ( ! empty( $term_description ) ) :
				printf( '<div class="taxonomy-description">%s</div>', $term_description );
			endif;
		?>

		<div class="entry-meta"><?php echo sprintf( esc_html( _n( '%s post found', '%s posts found', $wp_query->found_posts, 'ux-shop' ) ), $wp_query->found_posts ); ?></div>
	</header><!-- .page-header -->
	<?php do_action( 'shrk-page-cover-after' ); ?>
</div>

<div class="container container-main-content">
	<div class="row">
		<div class="main-content-inner col-12 <?php echo esc_attr(shrk_get_main_inner_class()); ?>">            

			<div class="content-padder">
				
				<?php if ( have_posts() ) : ?>
				
					<?php /* Start the Loop */ ?>
					<?php while ( have_posts() ) : the_post(); ?>
			
						<?php
							get_template_part( 'content', get_post_format() );
						?>
			
					<?php endwhile; ?>
			
					<?php shrk_content_nav( 'nav-below', 'container' ); ?>
			
				<?php else : ?>
			
					<?php get_template_part( 'no-results', 'archive' ); ?>
			
				<?php endif; ?>
			
			</div><!-- .content-padder -->
			
			<?php get_sidebar(); ?>

        </div><!-- close .*-inner (main-content or sidebar, depending if sidebar is used) -->
    </div><!-- close .row -->
</div><!-- close .container .container-main-content -->
<?php get_footer(); ?>
