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

<main id="main" role="main">
  <?php do_action( 'sauna_lite_before_slider' ); ?>
  
  <?php if( get_theme_mod('sauna_lite_slider_hide', false) != '' || get_theme_mod( 'sauna_lite_mobile_media_slider', true) != ''){ ?>
    <section id="slider">
      <div id="carouselExampleIndicators" class="carousel slide carousel-fade" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'sauna_lite_slider_speed',3000)) ?>"> 
        <?php $sauna_lite_slider_pages = array();
          for ( $count = 1; $count <= 4; $count++ ) {
            $mod = intval( get_theme_mod( 'sauna_lite_slidersettings-page-' . $count ));
            if ( 'page-none-selected' != $mod ) {
              $sauna_lite_slider_pages[] = $mod;
            }
          }
          if( !empty($sauna_lite_slider_pages) ) :
            $args = array(
              'post_type' => 'page',
              'post__in' => $sauna_lite_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 the_permalink(); ?>">
              <?php if(has_post_thumbnail()){
                  the_post_thumbnail();
                } else{?>
                  <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/Banner-image.png" alt="" />
                <?php } ?></a>
              <div class="carousel-caption wow zoomIn">
                <div class="inner_carousel">
                  <?php if( get_theme_mod('sauna_lite_slider_title',true) != ''){ ?>
                   <h1 class="my-3 p-0"><?php the_title(); ?></h1>
                   <?php }?>
                   <?php if( get_theme_mod('sauna_lite_slider_content',true) != ''){ ?>
                   <p class="mb-3"><?php $sauna_lite_excerpt = get_the_excerpt(); echo esc_html( sauna_lite_string_limit_words( $sauna_lite_excerpt,esc_attr(get_theme_mod('sauna_lite_slider_excerpt_length','20')) ) ); ?></p>
                   <?php }?>
                  <?php if ( get_theme_mod('sauna_lite_slider_button_text','LEARN MORE') != '' && get_theme_mod('sauna_lite_slider_button',true) != '' || get_theme_mod('sauna_lite_slider_button_responsive',true) != ''|| get_theme_mod('sauna_lite_slider_button_link') != '') {?>
                    <div class="more-btn">              
                      <a href="<?php echo esc_url(get_theme_mod('sauna_lite_slider_button_link')!= '') ? esc_url(get_theme_mod('sauna_lite_slider_button_link')) : esc_url(get_permalink()); ?>" class="hvr-sweep-to-right"><?php echo esc_html( get_theme_mod('sauna_lite_slider_button_text',__('LEARN MORE', 'sauna-lite')) ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('sauna_lite_slider_button_text',__('LEARN MORE', 'sauna-lite')) ); ?></span></a>
                    </div>
                  <?php }?>
                </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('sauna_lite_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('sauna_lite_slider_prev_icon','fas fa-chevron-left')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Previous', 'sauna-lite' );?></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('sauna_lite_slider_next_icon','fas fa-chevron-right')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Next', 'sauna-lite' );?></span>
        </a>
        <?php }?>
      </div>  
      <div class="clearfix"></div>
    </section>
  <?php }?>

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

  <?php if( get_theme_mod('sauna_lite_sec1_title') != ''){ ?>
    <?php /*--OUR SERVICES--*/?>
    <section id="services-sec" class="py-4">
      <div class="container">
  	    <div class="service-title mb-5 wow bounceInUp">
	        <?php if( get_theme_mod('sauna_lite_sec1_title') != ''){ ?>
            <h2><?php echo esc_html(get_theme_mod('sauna_lite_sec1_title','')); ?></h2>  
	        <div class="images_border">
            <img role="img" src="<?php echo esc_url(get_template_directory_uri().'/images/heading-boder.png' ); ?>" alt="<?php esc_attr_e( 'Heading Image', 'sauna-lite' );?>">
	        </div>
	        <?php }?>
  	    </div>
  	    <div class="row">
    			<?php $sauna_lite_slider_pages = array();
    			for ( $count = 0; $count <= 3; $count++ ) {
    				$mod = absint( get_theme_mod( 'sauna_lite_services_sec_ettings-page-' . $count ));
    				if ( 'page-none-selected' != $mod ) {
    				  $sauna_lite_slider_pages[] = $mod;
    				}
    			}
    			if( !empty($sauna_lite_slider_pages) ) :
    			  $args = array(
    			    'post_type' => 'page',
    			    'post__in' => $sauna_lite_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="col-lg-4 col-md-4 service-box mb-4">
  						    <div class="service-imagebox wow zoomIn">
						        <?php the_post_thumbnail(); ?>
  						    </div>
  						    <div class="service-content wow zoomIn">
						        <h4><?php the_title(); ?></h4>
						        <?php the_excerpt(); ?>
                    <div class="service-btn mt-3">
                      <a href="<?php the_permalink(); ?>" class="read-btn"><?php echo esc_html( get_theme_mod('sauna_lite_services_sec_button_text',__('Read More', 'sauna-lite')) ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('sauna_lite_services_sec_button_text',__('Read More', 'sauna-lite')) ); ?></span></a>
                    </div>
						        <div class="clearfix"></div>
  						    </div>
    						</div>
    					<?php $count++; endwhile; 
    					wp_reset_postdata();
    					?>
    			  <?php else : ?>
  			      <div class="no-postfound"></div>
    			  <?php endif;
    			endif;?>
  		  </div>
  	    <div class="clearfix"></div>
  	  </div> 
    </section>
  <?php }?>

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

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

<?php get_footer(); ?>