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

<main id="main" role="main">
  
<?php if( get_theme_mod( 'feminine_style_lite_slider_hide_show', false ) != '' || get_theme_mod( 'feminine_style_lite_slider_responsive', true ) != '' ) {?>
    <div class="slider-section position-relative">
      <section id="slider">
        <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel" data-bs-interval="3000"> 
          <?php $feminine_style_lite_slider_pages = array();
            for ( $count = 1; $count <= 4; $count++ ) {
              $mod = intval( get_theme_mod( 'feminine_style_lite_slider_page' . $count ));
              if ( 'page-none-selected' != $mod ) {
                $feminine_style_lite_slider_pages[] = $mod;
              }
            }
            if( !empty($feminine_style_lite_slider_pages) ) :
              $args = array(
                'post_type' => 'page',
                'post__in' => $feminine_style_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"';}?>>
              <div class="slider-bgimage">
                <?php if(get_theme_mod('feminine_style_lite_slider_background_img') != ''){ ?>
                  <img src="<?php echo esc_url(get_theme_mod('feminine_style_lite_slider_background_img')); ?>" alt="<?php echo esc_attr('Slider Background Image', 'feminine-style-lite'); ?>">
                <?php } else{?>
                  <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/slider-image.png" alt="" />
                <?php } ?>
              </div>
              <div class="carousel-caption">
                <div class="row">
                  <div class="col-lg-7 col-md-7 align-self-center">
                    <div class="inner_carousel wow zoomIn">
                        <?php if( get_theme_mod('feminine_style_lite_slider_small_title') != '' ){ ?>
                          <div class="mb-1 wow bounceInUp" data-wow-duration="2s">
                            <span class="slider-badge mb-1"><?php echo esc_html(get_theme_mod('feminine_style_lite_slider_small_title',''));?></span>
                          </div>
                        <?php }?>
                        <?php if( get_theme_mod('feminine_style_lite_slider_title',true) != ''){ ?>
                          <h1 class="my-3 p-0"><?php the_title(); ?></h1>
                        <?php }?>
                        <?php if( get_theme_mod('feminine_style_lite_slider_content',true) != ''){ ?>
                          <p class="mb-3"><?php $feminine_style_lite_excerpt = get_the_excerpt(); echo esc_html( feminine_style_lite_string_limit_words( $feminine_style_lite_excerpt,esc_attr(get_theme_mod('feminine_style_lite_slider_excerpt_length','20')))); ?></p>
                        <?php }?>
                        <?php if(get_theme_mod('feminine_style_lite_slider_button',true) != '' || get_theme_mod('feminine_style_lite_slider_button_responsive',true) != ''|| get_theme_mod('feminine_style_lite_slider_button_text','READ MORE') != ''|| get_theme_mod('feminine_style_lite_slider_button_link') != '') {?> 
                          <div class="read-btn mt-lg-4">
                            <a href="<?php echo esc_url(get_theme_mod('feminine_style_lite_slider_button_link')!= '') ? esc_url(get_theme_mod('feminine_style_lite_slider_button_link')) : esc_url(get_permalink()); ?>" class="blogbutton-small"><?php echo esc_html(get_theme_mod('feminine_style_lite_slider_button_text',__('READ MORE', 'feminine-style-lite'))); ?><span class="screen-reader-text"><?php echo esc_html('READ MORE', 'feminine-style-lite'); ?></span>
                            </a>
                          </div>
                        <?php }?>   
                    </div>
                  </div>
                  <div class="col-lg-5 col-md-5 align-self-center">
                    <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/grouped-image.png" alt="" />
                    <?php } ?>
                    <span class="screen-reader-text"><?php esc_html_e( 'Slider Image','feminine-style-lite');?> </a>
                  </div>
                </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('feminine_style_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('feminine_style_lite_slider_prev_icon','fas fa-chevron-left')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Previous','feminine-style-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('feminine_style_lite_slider_next_icon','fas fa-chevron-right')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Next','feminine-style-lite');?></span>
          </a>
          <?php }?>
        </div> 
      </section> 
    </div>
  <?php }?>

  <?php do_action( 'feminine_style_lite_before_product_section' ); ?>
    <?php if( get_theme_mod('feminine_style_lite_about_hide_show', false )) {?>
      <section id="about-section" class="py-5">
        <div class="container">
          <?php $feminine_style_lite_about_page = array();
            $mod = absint( get_theme_mod( 'feminine_style_lite_about_page'));
            if ( 'page-none-selected' != $mod ) {
              $feminine_style_lite_about_page[] = $mod;
            }
            if( !empty($feminine_style_lite_about_page) ) :
              $args = array(
                'post_type' => 'page',
                'post__in' => $feminine_style_lite_about_page,
                'orderby' => 'post__in'
              );
              $query = new WP_Query( $args );
              if ( $query->have_posts() ) :
                $count = 0;
                while ( $query->have_posts() ) : $query->the_post(); ?>
                  <div class="row">
                    <div class="col-lg-6 col-md-6 col-sm-6">
                      <?php if(has_post_thumbnail()) {?>
                        <div class="image-box position-relative wow fadeInLeft">
                          <?php the_post_thumbnail(); ?>
                          <span><?php the_title(); ?></span>
                        </div>
                      <?php }?>
                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-6 wow fadeInRight">
                      <?php if(get_theme_mod('feminine_style_lite_small_title') != ''){ ?>
                        <strong><?php echo esc_html(get_theme_mod('feminine_style_lite_small_title')); ?></strong>
                      <?php }?>
                        <h3><?php the_title(); ?></h3>
                        <p><?php $feminine_style_lite_excerpt = get_the_excerpt(); echo esc_html( feminine_style_lite_string_limit_words( $feminine_style_lite_excerpt, 20)); ?></p>
                      <?php
                        $feminine_style_lite_service_category = get_theme_mod('feminine_style_lite_service_category');
                        if($feminine_style_lite_service_category){
                          $page_query = new WP_Query(array( 'category_name' => esc_html( $feminine_style_lite_service_category ,'feminine-style-lite')));
                          while( $page_query->have_posts() ) : $page_query->the_post(); ?>
                            <div class="row mb-3">
                              <div class="col-lg-3 col-md-3 col-4 align-self-center text-center">
                                <?php if(has_post_thumbnail()) {?>
                                  <div class="service-img">
                                    <?php the_post_thumbnail(); ?>
                                  </div>
                                <?php }?>
                              </div>
                              <div class="col-lg-9 col-md-9 col-8 align-self-center">
                                <div class="service-content">
                                  <h4><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h4>
                                  <p><?php $feminine_style_lite_excerpt = get_the_excerpt(); echo esc_html( feminine_style_lite_string_limit_words( $feminine_style_lite_excerpt, 15)); ?></p>
                                </div>
                              </div>
                            </div>
                          <?php endwhile;
                          wp_reset_postdata();
                        }
                      ?>
                    </div>
                  </div>
                <?php endwhile; ?>
              <?php else : ?>
                <div class="no-postfound"></div>
              <?php endif;
            endif;
            wp_reset_postdata();
          ?>
        </div>
      </section>
    <?php }?>
  <?php do_action( 'feminine_style_lite_after_product_section' ); ?>

  <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(); ?>