<?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://codex.wordpress.org/Template_Hierarchy
 *
 * @package Spirit Business
 */

get_header(); ?>

	<?php if( !is_paged() ) {

		$spirit_business_enable_featured_slider_section = spirit_business_get_option( 'enable_featured_slider_section' );
		$spirit_business_enable_our_services_section    = spirit_business_get_option( 'enable_our_services_section' );
		$spirit_business_enable_call_to_action_section  = spirit_business_get_option( 'enable_call_to_action_section' );

		if( true == $spirit_business_enable_featured_slider_section && is_home() ):
            get_template_part( 'sections/section', 'featured-slider' ); ?>
        <?php endif;

        if( true == $spirit_business_enable_our_services_section && is_home() ):
            get_template_part( 'sections/section', 'our-services' ); ?>
        <?php endif;

    	if( true == $spirit_business_enable_call_to_action_section && is_home() ):
            get_template_part( 'sections/section', 'call-to-action' ); ?>
        <?php endif;

	} ?>
		
	<div id="content-wrapper" class="section-gap">
		<?php 
		$spirit_business_enable_latest_posts_section 	 = spirit_business_get_option( 'enable_latest_posts_section' );
		$spirit_business_latest_posts_section_sub_title  = spirit_business_get_option( 'latest_posts_section_sub_title' );
		$spirit_business_latest_posts_section_title      = spirit_business_get_option( 'latest_posts_section_title' );

    	if( true == $spirit_business_enable_latest_posts_section && is_home() ): ?>
			<div class="wrapper clear">
				<div id="primary" class="content-area">
					<main id="main" class="site-main blog-posts-wrapper" role="main">
						<?php if( !empty( $spirit_business_latest_posts_section_sub_title ) || !empty( $spirit_business_latest_posts_section_title ) ) : ?>
		                    <div class="section-header">
		                        <p class="section-subtitle"><?php echo esc_html($spirit_business_latest_posts_section_sub_title);?></p>
		                        <h2 class="section-title"><?php echo esc_html($spirit_business_latest_posts_section_title);?></h2>
		                    </div><!-- .section-header -->
		                <?php endif; ?>

						<div class="section-content col-3 clear">
							<?php
							if ( have_posts() ) :

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

									/*
									 * Include the Post-Format-specific template for the content.
									 * If you want to override this in a child theme, then include a file
									 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
									 */
									get_template_part( 'template-parts/content', get_post_format() );

								endwhile;
							else :

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

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

						<?php the_posts_pagination(); ?>
					</main><!-- #main -->
				</div><!-- #primary -->

				<?php get_sidebar(); ?>
			</div><!-- .section-gap -->
		<?php endif; ?>
	</div><!-- #content-wrapper -->

<?php
get_footer();
