<?php
/**
 * The template for displaying home page.
 *
 * Template Name: Custom Home Page
 *
 * @package Medical Supplements Store
 */
get_header(); ?>

<main id="main" role="main">
	<?php do_action( 'medical_supplements_store_before_slider' ); ?>

	<?php if( get_theme_mod('medical_supplements_store_slider_arrows', false) != '' || get_theme_mod( 'medical_supplements_store_mobile_media_slider', true) != ''){ ?>
		<section id="slider">
		  	<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'medical_supplements_store_slider_speed',3000)) ?>"> 
			    <?php $medical_supplements_store_slider_pages = array();
			      	for ( $count = 1; $count <= 4; $count++ ) {
				        $mod = intval( get_theme_mod( 'medical_supplements_store_slidersettings_page' . $count ));
				        if ( 'page-none-selected' != $mod ) {
				          $medical_supplements_store_slider_pages[] = $mod;
				        }
			      	}
			      	if( !empty($medical_supplements_store_slider_pages) ) :
			        $args = array(
			          	'post_type' => 'page',
			          	'post__in' => $medical_supplements_store_slider_pages,
			          	'orderby' => 'post__in'
			        );
			        $query = new WP_Query( $args );
			        if ( $query->have_posts() ) :
			          $i = 1;
			    ?>     
			    <div class="carousel-inner" role="listbox">
			      	<?php  while ( $query->have_posts() ) : $query->the_post(); ?>
			        <div <?php if($i == 1){echo 'class="carousel-item active"';} else{ echo 'class="carousel-item"';}?>>
			          	<a href="<?php echo esc_url( get_permalink() );?>"><?php if(has_post_thumbnail()){
                         	the_post_thumbnail();
                        } else{?>
                       		<img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/Banner.png" alt="" />
                       	<?php } ?>
                       	<span class="screen-reader-text"><?php esc_html(the_title()); ?></span></a>
			          	<div class="carousel-caption wow zoomIn">
				            <div class="inner_carousel">
                                <?php if( get_theme_mod('medical_supplements_store_slider_title',true) != ''){ ?>
                                <h1 class="my-3 p-0"><?php the_title(); ?></h1>
				                <?php }?>
				                <?php if( get_theme_mod('medical_supplements_store_slider_content',true) != ''){ ?>
				                <p class="mb-3"><?php $medical_supplements_store_excerpt = get_the_excerpt(); echo esc_html( medical_supplements_store_string_limit_words( $medical_supplements_store_excerpt,esc_attr(get_theme_mod('medical_supplements_store_slider_excerpt_length','20')))); ?></p>
				                <?php }?>
				              	<span class="screen-reader-text"><?php esc_html(the_title()); ?></span>
				            </div>
			          	</div>
			        </div>
			      	<?php $i++; endwhile;
			      	wp_reset_postdata();?>
			    </div>
			    <?php else : ?>
			    <div class="no-postfound"></div>
			        <?php endif;
			    endif;?>
				<?php if( get_theme_mod('medical_supplements_store_slider_arrow',true) != ''){ ?>
			    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-bs-slide="prev">
			        <span class="carousel-control-prev-icon" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('medical_supplements_store_slider_prev_icon','fas fa-chevron-left')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Previous','medical-supplements-store' );?></span>
			    </a>
			    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-bs-slide="next">
			        <span class="carousel-control-next-icon" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('medical_supplements_store_slider_next_icon','fas fa-chevron-right')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Next','medical-supplements-store' );?></span>
			    </a>
				<?php }?>
		  	</div>
		  	<div class="clearfix"></div>
		</section>
	<?php }?>
	<?php do_action( 'medical_supplements_store_after_slider' ); ?>

	<?php if( get_theme_mod('medical_supplements_store_delivery') != ''){ ?>
		<div id="custom-page-services" class="py-3">
			<div class="container">
				<div class="row wow bounceInUp">
					<div class="col-lg-3 col-md-3">
						<div class="row">
					      	<?php if( get_theme_mod( 'medical_supplements_store_delivery','' ) != '') { ?>
						      	<div class="col-lg-3 col-md-3 col-3">
						      		<i class="fas fa-truck mb-md-0 mb-4"></i>
						      	</div>
						      	<div class="col-lg-9 col-md-9 col-9">
						      		<strong><?php echo esc_html( get_theme_mod('medical_supplements_store_delivery','') ); ?></strong>
						      		<p class="m-0"><?php echo esc_html( get_theme_mod('medical_supplements_store_delivery_line','') ); ?></p>
						      	</div>
					      	<?php } ?>
				      	</div>
				  	</div>
				 	<div class="col-lg-3 col-md-3">
				 		<div class="row">
					  		<?php if( get_theme_mod( 'medical_supplements_store_return','' ) != '') { ?>
					  			<div class="col-lg-3 col-md-3 col-3">
						      		<i class="fas fa-share mb-md-0 mb-4"></i>
						      	</div>
						      	<div class="col-lg-9 col-md-9 col-9">
						      		<strong><?php echo esc_html( get_theme_mod('medical_supplements_store_return','')); ?></strong>
						      		<p class="m-0"><?php echo esc_html( get_theme_mod('medical_supplements_store_return_line','')); ?></p>
						      	</div>
					  		<?php } ?>
					  	</div>
				    </div>
				    <div class="col-lg-3 col-md-3">
				    	<div class="row">
					    	<?php if( get_theme_mod( 'medical_supplements_store_satisfy','' ) != '') { ?>
						    	<div class="col-lg-3 col-md-3 col-3">
							      	<i class="fas fa-thumbs-up mb-md-0 mb-4"></i>
						      	</div>
						      	<div class="col-lg-9 col-md-9 col-9">
						      		<strong><?php echo esc_html( get_theme_mod('medical_supplements_store_satisfy','')); ?></strong>
						      		<p class="m-0"><?php echo esc_html( get_theme_mod('medical_supplements_store_satisfy_line','')); ?></p>
						      	</div>
					  		<?php } ?>
					  	</div>
				    </div>
				    <div class="col-lg-3 col-md-3">
				    	<div class="row">
					  		<?php if( get_theme_mod( 'medical_supplements_store_points','' ) != '') { ?>
					  			<div class="col-lg-3 col-md-3  col-3">
							      	<i class="fas fa-star mb-md-0 mb-4"></i>
						      	</div>
						      	<div class="col-lg-9 col-md-9 col-9">
						      		<strong><?php echo esc_html( get_theme_mod('medical_supplements_store_points','')); ?></strong>
						      		<p class="m-0"><?php echo esc_html( get_theme_mod('medical_supplements_store_points_line','')); ?></p>
						      	</div>
					    	<?php } ?>
					    </div>
				    </div>
				</div>
			</div>
		</div>	
	<?php }?>

	<?php do_action( 'medical_supplements_store_after_service' ); ?>

	<?php if( get_theme_mod('medical_supplements_store_sec1_title') != ''){ ?>
		<section id="our-products" class="py-5">
			<div class="container wow zoomIn">
		        <?php if( get_theme_mod('medical_supplements_store_sec1_title') != ''){ ?>
		            <strong><?php echo esc_html(get_theme_mod('medical_supplements_store_sec1_title','')); ?></strong>
		        <?php }?>
				<?php $medical_supplements_store_slider_pages = array();
				$mod = intval( get_theme_mod( 'medical_supplements_store_product_page'));
				if ( 'page-none-selected' != $mod ) {
				  $medical_supplements_store_slider_pages[] = $mod;
				}
				if( !empty($medical_supplements_store_slider_pages) ) :
				    $args = array(
					    'post_type' => 'page',
					    'post__in' => $medical_supplements_store_slider_pages,
					    'orderby' => 'post__in'
				    );
				    $query = new WP_Query( $args );
				    if ( $query->have_posts() ) :
				    	$count = 0;
						while ( $query->have_posts() ) : $query->the_post(); ?>
						    <div class="box-image">
						        <p><?php the_content(); ?></p>
						        <div class="clearfix"></div>
						    </div>
						<?php $count++; endwhile; ?>
				    <?php else : ?>
				        <div class="no-postfound"></div>
				    <?php endif;
				endif;
				wp_reset_postdata(); ?>
			    <div class="clearfix"></div>		
			</div>
		</section>
	<?php }?>

	<?php do_action( 'medical_supplements_store_after_product' ); ?>

	<div id="content-ma">
		<div class="container entry-content">
		  	<?php while ( have_posts() ) : the_post(); ?>
		    	<?php the_content(); ?>
		  	<?php endwhile; // end of the loop. ?>
		</div>
	</div>
</main>

<?php get_footer(); ?>