<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package rubik_news
 */

get_header();

$disable_recent_posts = get_theme_mod( 'disable_recent_posts', false );
?>

<div id="content-wrap" class="container">
	<?php get_template_part( 'template-parts/homepage/breaking-news' ); ?>
	<?php get_template_part( 'template-parts/homepage/featured-news' ); ?>
	<?php get_template_part( 'template-parts/homepage/trending-news' ); ?>

	<div id="primary" class="content-area">
		<main id="main" class="site-main">
			<?php
			get_template_part(
				'template-parts/homepage/latest-featured-posts'
			);

			get_template_part(
				'template-parts/homepage/politics-business'
			);
			?>

			<?php if ( ! is_home() || ! $disable_recent_posts ) : ?>
				<div class="blog-archive columns-3 clear">
					<?php
					if ( have_posts() ) :
						/* Start the Loop. */
						while ( have_posts() ) :
							the_post();

							/*
							 * Include the Post-Type-specific template.
							 *
							 * To override this in a child theme, add a file
							 * named content-___.php, where ___ is the post type.
							 */
							get_template_part(
								'template-parts/content',
								get_post_type()
							);

						endwhile;

					else :

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

					endif;
					?>
				</div><!-- .blog-archive -->

				<?php
				the_posts_pagination(
					array(
						'prev_text'          => rubik_news_get_svg(
							array(
								'icon' => 'arrow-left',
							)
						) . '<span class="screen-reader-text">'
							. __(
								'Previous page',
								'rubik-news'
							)
							. '</span>',

						'next_text'          => '<span class="screen-reader-text">'
							. __(
								'Next page',
								'rubik-news'
							)
							. '</span>'
							. rubik_news_get_svg(
								array(
									'icon' => 'arrow-right',
								)
							),

						'before_page_number' => '<span class="meta-nav screen-reader-text">'
							. __(
								'Page',
								'rubik-news'
							)
							. ' </span>',
					)
				);
				?>
			<?php endif; ?>
		</main><!-- #main -->
	</div><!-- #primary -->

	<?php get_sidebar(); ?>
</div><!-- .container -->

<?php
get_footer();