<?php
/**
 * Template Name: Home Template
 */

get_header(); ?>

<?php
  $smart_cleaning_year  = get_the_time('Y');
  $smart_cleaning_month = get_the_time('m');
  $smart_cleaning_day   = get_the_time('d');
?>

<main id="skip-content">
  <section id="top-slider" slider-loop="<?php echo esc_html(get_theme_mod('smart_cleaning_slider_loop')); ?>">
     <?php if(get_theme_mod('smart_cleaning_blog_slider_setting',true)){ ?>
    <?php $smart_cleaning_slide_pages = array();
      for ( $handyman_cleaning_service_count = 1; $handyman_cleaning_service_count <= 3; $handyman_cleaning_service_count++ ) {
        $smart_cleaning_service_mod = intval( get_theme_mod( 'smart_cleaning_top_slider_page' . $handyman_cleaning_service_count ));
        if ( 'page-none-selected' != $smart_cleaning_service_mod ) {
          $smart_cleaning_slide_pages[] = $smart_cleaning_service_mod;
        }
      }
      if( !empty($smart_cleaning_slide_pages) ) :
        $handyman_cleaning_service_args = array(
          'post_type' => 'page',
          'post__in' => $smart_cleaning_slide_pages,
          'orderby' => 'post__in'
        );
        $handyman_cleaning_service_query = new WP_Query( $handyman_cleaning_service_args );
        if ( $handyman_cleaning_service_query->have_posts() ) :
          $i = 1;
    ?>
    <div class="owl-carousel" role="listbox">
      <?php  while ( $handyman_cleaning_service_query->have_posts() ) : $handyman_cleaning_service_query->the_post(); ?>
        <div class="slider-box">
          <?php if(has_post_thumbnail()){
            the_post_thumbnail();
            } else{?>
            <img src="<?php echo esc_url(get_theme_file_uri()); ?>/assets/img/slider.png" alt="" />
          <?php } ?>
          <div class="slider-inner-box">
            <?php if(get_theme_mod('smart_cleaning_slider_title_setting',1) == 1){ ?>
              <h2><?php the_title(); ?></h2>
            <?php }?>
            <?php if(get_theme_mod('smart_cleaning_slider_content_setting',1) == 1){ ?>
              <p><?php $handyman_cleaning_service_excerpt = get_the_excerpt(); echo esc_html( smart_cleaning_string_limit_words( $handyman_cleaning_service_excerpt, esc_attr(get_theme_mod('smart_cleaning_slider_excerpt_length', 20)) )); ?></p>
            <?php }?>
            <?php if(get_theme_mod('smart_cleaning_slider_button_setting',1) == 1 && get_theme_mod('smart_cleaning_slider_button_text','Book Online') != ''){ ?>
              <div class="slide-btn my-4"><a href="<?php the_permalink(); ?>"><?php esc_html_e(get_theme_mod('smart_cleaning_slider_button_text','Book Online')); ?></a></div>
            <?php }?>
          </div>
        </div>
      <?php $i++; endwhile;
      wp_reset_postdata();?>
    </div>
    <?php else : ?>
      <div class="no-postfound"></div>
    <?php endif;
    endif;?>
    <?php }?>
  </section>

<?php if(get_theme_mod('smart_cleaning_blog_service_setting',true)){ ?>
  <section id="featured-topic" class="py-5">
    <div class="container">
      <h3 class="mb-5 text-center "><?php echo esc_html(get_theme_mod('smart_cleaning_featured_category_title','')); ?></h3>
      <div class="row">
        <?php
          $smart_cleaning_featured_cat1 = get_theme_mod('smart_cleaning_featured_category_1','');
          if($smart_cleaning_featured_cat1){
            $smart_cleaning_page_query4 = new WP_Query(array( 'category_name' => esc_html($smart_cleaning_featured_cat1,'handyman-cleaning-service')));
            while( $smart_cleaning_page_query4->have_posts() ) : $smart_cleaning_page_query4->the_post(); ?>
              <div class="col-lg-6 col-md-4">
                <div class="featured-imagebox mb-4">
                  <div class="row">
                    <div class="col-lg-5 col-md-12 align-self-center">
                      <?php the_post_thumbnail(); ?>
                    </div>
                    <div class="col-lg-7 col-md-12 align-self-center">
                      <h4 class="mt-2"><?php the_title(); ?></h4>
                      <p><?php $handyman_cleaning_service_excerpt = get_the_excerpt(); echo esc_html( smart_cleaning_string_limit_words( $handyman_cleaning_service_excerpt, 15 )); ?></p>
                      <a href="<?php the_permalink(); ?>"><?php esc_html_e('READ MORE','handyman-cleaning-service'); ?></a>
                    </div>
                  </div>
                </div>
              </div>
            <?php endwhile;
          wp_reset_postdata();
        } ?>
      </div>
    </div>
  </section>
 <?php }?>

<?php if(get_theme_mod('handyman_cleaning_service_topics_setting',true)){ ?>
  <section id="services-topic" class="py-5">
    <div class="container">
      <?php if(get_theme_mod('handyman_cleaning_service_services_category_title') != ''){ ?>
        <h3 class="mb-5 text-center "><?php echo esc_html(get_theme_mod('handyman_cleaning_service_services_category_title','')); ?></h3>
      <?php }?>
      <div class="row">
        <?php
          $handyman_cleaning_service_catData = get_theme_mod('handyman_cleaning_service_menu_items','');
          if($handyman_cleaning_service_catData){
            $handyman_cleaning_service_page_query = new WP_Query(array( 'category_name' => esc_html($handyman_cleaning_service_catData,'handyman-cleaning-service')));
            while( $handyman_cleaning_service_page_query->have_posts() ) : $handyman_cleaning_service_page_query->the_post(); ?>
              <div class="col-lg-4 col-md-6 col-sm-6">
                <div class="box mb-4">
                  <?php the_post_thumbnail(); ?>
                  <div class="box-cont p-2">
                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    <p><?php $handyman_cleaning_service_excerpt = get_the_excerpt(); echo esc_html( smart_cleaning_string_limit_words( $handyman_cleaning_service_excerpt, 5 )); ?></p>
                  </div>
                </div>
              </div>
            <?php endwhile;
            wp_reset_postdata();
          } ?>
      </div>
    </div>
  </section>
  <?php }?>

  <section id="content-section" class="container">
    <?php
      if ( have_posts() ) :
        while ( have_posts() ) : the_post();
          the_content();
        endwhile;
      endif;
    ?>
  </section>
</main>

<?php get_footer(); ?>
