<?php
/**
 * The template for displaying archive pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package    Wira
 * @since      1.0.0
 */

?>

<?php get_header(); ?>

<!-- Main Wrapper -->
<main id="main">

	<!-- Theme Wrapper -->
	<div class="wira-theme">

		<!-- Title Banner -->
		<?php get_template_part( 'template-parts/title-banner' ); ?>

		<!-- Main Section Wrapper -->
		<div class="container theme-section theme-space-wider">

			<!-- Row -->
			<div class="row gx-lg-5 gy-5">

				<!-- Main Content Columns -->
				<div class="col">

					<!-- Search Count Label -->
					<?php if ( have_posts() ) : ?>
						<h4 class="mb-4">
							<?php
								$wira_search_query  = get_search_query();
								$wira_total_results = $wp_query->found_posts;
								$wira_before_count  = get_theme_mod( 'wira_search_before_count', __( 'Found', 'wira' ) );
								$wira_after_count   = get_theme_mod( 'wira_search_after_count', __( 'post result on', 'wira' ) );

								echo wp_kses_post(
									sprintf(
										'%s <span class="theme-search-count-label theme-color-primary">%d</span> %s "%s"',
										esc_html( $wira_before_count ),
										$wira_total_results,
										esc_html( $wira_after_count ),
										esc_html( $wira_search_query )
									)
								);
							?>
						</h4>
					<?php endif; ?>

					<!-- Post Content Row -->
					<div class="row row-cols-md-2 row-cols-1 gy-4 gx-lg-4">

						<!-- Post Content Looping -->
						<?php
						if ( have_posts() ) :
							while ( have_posts() ) :
								the_post();
								get_template_part( 'template-parts/content/content' );
							endwhile;

						else :
							get_template_part( 'template-parts/content/content', 'none' );
						endif;
						?>
					</div> <!-- Post Content Row /End -->

					<!-- Post Pagination -->
					<?php

					if ( class_exists( 'Wira\Templates\Custom_Pagination' ) ) {
						$wira_pagination = new Wira\Templates\Custom_Pagination();
						$wira_pagination->render();
					}
					?>
				</div> <!-- Main Content Columns /End -->

				<!-- Sidebar Columns -->
				<?php get_sidebar(); ?>
			</div> <!-- Row /End -->
		</div> <!-- Main Section Wrapper /End -->
	</div> <!-- Theme Wrapper /End -->
</main> <!-- Main Wrapper /End -->

<?php get_footer(); ?>
