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

get_header(); ?>

<main id="skip-content">
  <section id="top-slider">
    <?php if (get_theme_mod( 'camping_zone_slider_background_image' )) { ?>
        <img class="slider-bg-img" src="<?php echo esc_url( get_theme_mod( 'camping_zone_slider_background_image' )); ?>">
    <?php } else { ?>
      <div class="main-slider-bg"></div>
    <?php }
     ?>
  <div class="main-slider">
    <div class="container">
      <?php $camping_zone_slide_pages = array();
        for ( $camping_zone_count = 1; $camping_zone_count <= 3; $camping_zone_count++ ) {
          $camping_zone_mod = intval( get_theme_mod( 'camping_zone_top_slider_page' . $camping_zone_count ));
          if ( 'page-none-selected' != $camping_zone_mod ) {
            $camping_zone_slide_pages[] = $camping_zone_mod;
          }
        }
        if( !empty($camping_zone_slide_pages) ) :
          $camping_zone_args = array(
            'post_type' => 'page',
            'post__in' => $camping_zone_slide_pages,
            'orderby' => 'post__in'
          );
          $camping_zone_query = new WP_Query( $camping_zone_args );
          if ( $camping_zone_query->have_posts() ) :
            $i = 1;
        ?>
        <div class="owl-carousel" role="listbox">
          <?php  while ( $camping_zone_query->have_posts() ) : $camping_zone_query->the_post(); ?>
            <div class="slide-box row m-0 pt-5">
              <div class="col-lg-6 col-md-6 col-sm-12 col-12 align-self-center">
                <div class="slider-inner-box">
                  <h3 class="m-0"><?php the_title(); ?></h3>
                  <p class="content mt-3"><?php echo esc_html( wp_trim_words( get_the_content(), esc_attr(get_theme_mod('camping_zone_slider_excerpt_length', 15)) )); ?></p>
                  <div class="slide-btn mt-4">
                    <a href="<?php the_permalink(); ?>"><?php esc_html_e('DISCOVER MORE','camping-zone'); ?></a>
                  </div>
                </div>
              </div>
              <div class="slider-image col-lg-6 col-md-6 col-sm-12 col-12 align-self-center">
                <?php if (has_post_thumbnail()) { ?><img class="sider-img" src="<?php the_post_thumbnail_url('full'); ?>" /><?php } else { ?><div class="slide-bg"></div> <?php } ?>
                <?php if (get_theme_mod( 'camping_zone_slider_2_image' .$i )) { ?>
                  <img class="slider-2-img" src="<?php echo esc_url( get_theme_mod( 'camping_zone_slider_2_image' .$i)); ?>">
                <?php } ?>
              </div>
            </div>
          <?php $i++; endwhile;
          wp_reset_postdata();?>
        </div>
        <?php else : ?>
          <div class="no-postfound"></div>
        <?php endif;
        endif;?>
      </div>
    </div>
    <div class="social-link">
      <?php if(get_theme_mod('camping_zone_facebook_url') != ''){ ?>
        <a href="<?php echo esc_url(get_theme_mod('camping_zone_facebook_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('camping_zone_facebook_icon') ); ?>"></i></a>
      <?php }?>
      <?php if(get_theme_mod('camping_zone_twitter_url') != ''){ ?>
        <a href="<?php echo esc_url(get_theme_mod('camping_zone_twitter_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('camping_zone_twitter_icon') ); ?>"></i></a>
      <?php }?>
      <?php if(get_theme_mod('camping_zone_intagram_url') != ''){ ?>
        <a href="<?php echo esc_url(get_theme_mod('camping_zone_intagram_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('camping_zone_intagram_icon') ); ?>"></i></a>
      <?php }?>
      <?php if(get_theme_mod('camping_zone_linkedin_url') != ''){ ?>
        <a href="<?php echo esc_url(get_theme_mod('camping_zone_linkedin_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('camping_zone_linkedin_icon') ); ?>"></i></a>
      <?php }?>
      <?php if(get_theme_mod('camping_zone_pintrest_url') != ''){ ?>
        <a href="<?php echo esc_url(get_theme_mod('camping_zone_pintrest_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('camping_zone_pintrest_icon') ); ?>"></i></a>
      <?php }?>
    </div>
  </section>

  <section class="featured py-5">
    <div class="container">
      <div class="ser-heading text-center mb-4">
        <?php if(get_theme_mod('camping_zone_services_heading') != ''){ ?>
          <h4 class="main-heading "><?php echo esc_html(get_theme_mod('camping_zone_services_heading')); ?></h4>
        <?php }?>
        <?php if(get_theme_mod('camping_zone_services_content') != ''){ ?>
          <h3 class="main-heading"><?php echo esc_html(get_theme_mod('camping_zone_services_content')); ?></h3>
        <?php }?>
      </div>
      <div class="owl-carousel service-box m-0">
        <?php
          $camping_zone_services_cat = get_theme_mod('camping_zone_services_sec_category','');
          if($camping_zone_services_cat){
            $camping_zone_page_query5 = new WP_Query(array( 'category_name' => esc_html($camping_zone_services_cat,'camping-zone'),'posts_per_page' => 5));
            $i=1;
            while( $camping_zone_page_query5->have_posts() ) : $camping_zone_page_query5->the_post(); ?>
              <?php if(get_theme_mod('camping_zone_services_icon'.$i,'fas fa-stethoscope')){ ?>
                <div class="main-box">
                    <?php if ( has_post_thumbnail() ) { ?>
                      <div class="service-image">
                        <?php the_post_thumbnail( 'full' ); ?>
                      </div>
                    <?php } else { ?>
                      <div class="service-image">
                        <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider.png" alt="" />
                      </div>
                    <?php } ?>
                    <div class="ser-content">
                      <h4 class="my-2 text-center"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                      <div class="ser-btn">
                        <a href="<?php the_permalink(); ?>"><?php esc_html_e('Read More','camping-zone'); ?><i class="fas fa-arrow-right ms-2"></i></a>
                      </div>
                    </div>
                </div>
              <?php }?>
            <?php $i++; endwhile;
          wp_reset_postdata();
        } ?>
      </div>
    </div>
  </section>
  <section id="page-content">
    <div class="container">
      <div class="py-5">
        <?php
          if ( have_posts() ) :
            while ( have_posts() ) : the_post();
              the_content();
            endwhile;
          endif;
        ?>
      </div>
    </div>
  </section>
</main>

<?php get_footer(); ?>