<?php
/**
 * The template for displaying search results pages
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
 *
 * @package Blog Bee
 */
use BBE\Helpers as Helpers;
use BBE\Customizer\Section\Search_Page as Search_Page;
use BBE\Query_Manager as Query_Manager;
use BBE\Customizer\Section\Archives as Archives;
use BBE\Customizer\Section\You_May_Have_Missed as You_May_Have_Missed;

$archives = Archives::get_instance();
$masonry = $archives->get_masonry();
$layout = $archives->get_layout();

get_header();

	echo '<div class="bbe-sections-wrap">';

		Query_Manager::get_archive_opener();
		
			Search_Page::get_instance()->get_page_header( true );

			Search_Page::get_instance()->get_search_filter_block();

			ob_start();

				?>

					<main id="primary" class="site-main" <?php Helpers::the_aos_data_attr(); ?>>

						<?php
							if ( have_posts() ) :

								echo '<div class="article-wrap">';
								
									if( ( $layout !== 'list' ) && $masonry ) echo '<div class="bbe-masonry-sizer"></div>';

									/* Start the Loop */
									while ( have_posts() ) :
										the_post();

										/**
										 * Run the loop for the search to output the results.
										 * If you want to overload this in a child theme then include a file
										 * called content-search.php and that will be used instead.
										 */
										get_template_part( 'template-parts/content', 'search' );

									endwhile;

									wp_reset_postdata();
									
								echo '</div>';

								Search_Page::get_instance()->get_pagination();

							else :

								get_template_part( 'template-parts/content', 'none' );

							endif;
						?>

					</main><!-- #main -->

				<?php

			$content = ob_get_clean();
			
			$content_args = [
				'content'	=>	$content
			];

			get_template_part( 'template-parts/content', 'sidebar-reorder', $content_args );

		Query_Manager::get_archive_closer();

		You_May_Have_Missed::get_instance()->render_html();

	echo '</div><!-- .bbe-sections-wrap -->';
	
get_footer();
