<?php
$options = thrive_get_theme_options();

$sidebar_is_active = is_active_sidebar( 'sidebar-1' );

$next_page_link = get_next_posts_link();
$prev_page_link = get_previous_posts_link();

$section_class = _thrive_get_element_class( "content_section", $options );
?>

<?php get_header(); ?>

	<div class="wrp cnt <?php if ( $options['blog_layout'] == "grid_full_width" || $options['blog_layout'] == "grid_sidebar" ): ?> gin <?php endif; ?>">

		<?php if ( $options['sidebar_alignement'] == "left" && $sidebar_is_active && $options['blog_layout'] != "full_width" && $options['blog_layout'] != "grid_full_width" ): ?>
			<?php get_sidebar(); ?>
		<?php endif; ?>

		<?php if ( $options['blog_layout'] != "full_width" && $options['blog_layout'] != "grid_full_width" ): ?>
		<div class="bSeCont">
			<?php endif; ?>

			<section class="<?php echo $section_class; ?>">
				<?php if ( have_posts() ): ?>
					<?php $index = 0; ?>
					<?php while ( have_posts() ): ?>
						<?php the_post(); ?>
						<?php get_template_part( 'content', get_post_format() ); ?>
						<?php
						/**
						 * check if there is a focus area to be displayed between posts at current index
						 */
						$has_focus_area = thrive_check_blog_focus_area( $index + 1 );
						/**
						 * check if blog layout is one that can support displaying of focus areas (not grid or masonry)
						 */
						$accepted_layouts   = array( 'default', 'full_width' );
						$display_focus_area = $has_focus_area && in_array( $options['blog_layout'], $accepted_layouts );
						?>
						<?php if ( $display_focus_area ) : ?>
							<?php thrive_render_top_focus_area( "between_posts", $index + 1 ); ?>
						<?php endif; ?>
						<?php $index ++ ?>
					<?php endwhile; ?>
					<?php if ( _thrive_check_focus_area_for_pages( "archive", "bottom" ) ): ?>
						<?php if ( strpos( $options['blog_layout'], 'masonry' ) === false && strpos( $options['blog_layout'], 'grid' ) === false ): ?>
							<?php thrive_render_top_focus_area( "bottom", "archive" ); ?>
							<div class="spr"></div>
						<?php endif; ?>
					<?php endif; ?>

					<div class="clear"></div>
					<?php if ( $next_page_link || $prev_page_link && ( $next_page_link != "" || $prev_page_link != "" ) ): ?>
						<div class="awr ctr pgn">
							<?php thrive_pagination(); ?>
						</div>
						<div class="bspr"></div>
					<?php endif; ?>
				<?php else: ?>
					<!--No contents-->
				<?php endif ?>
				<div class="clear"></div>
			</section>
			<?php if ( $options['blog_layout'] != "full_width" && $options['blog_layout'] != "grid_full_width" ): ?>
		</div>
	<?php endif; ?>

		<?php if ( $options['sidebar_alignement'] == "right" && $sidebar_is_active && $options['blog_layout'] != "full_width" && $options['blog_layout'] != "grid_full_width" ): ?>
			<?php get_sidebar(); ?>
		<?php endif; ?>

		<div class="clear"></div>
	</div>

<?php get_footer(); ?>