<?php

/**
 * Template Name: Custom Home Page
 */

get_header();

?>
<main id="maincontent" role="main">
<?php 
  $forest_jungle_safari_number = get_theme_mod('forest_jungle_safari_slide_number');
  if($forest_jungle_safari_number != '')
?>
  <?php if( get_theme_mod( 'forest_jungle_safari_slider_hide_show', true) == 1 || get_theme_mod( 'forest_jungle_safari_resp_slider_hide_show', true) == 1) { ?>
    <section id ="slider" class="slider-sec position-relative pt-5">
      <div class="custom-cotnainer">
        <div id="carouselExampleCaptions"  class="carousel slide" data-bs-ride="carousel">
          <div class="d-flex slider-data container">
             <div class="carousel-indicators">
                <?php for ($forest_jungle_safari_i = 1; $forest_jungle_safari_i <= $forest_jungle_safari_number; $forest_jungle_safari_i++) { ?>
                  <button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="<?php echo ($forest_jungle_safari_i - 1); ?>" class="<?php if($forest_jungle_safari_i == 1){ echo "active"; } ?>" aria-current="<?php if($forest_jungle_safari_i == 1){ echo "true"; } ?>" aria-label="Slide <?php echo $forest_jungle_safari_i; ?>">
                  </button>
                <?php } ?>
              </div>
            <p class="page-num">
              <span class="current-page-num">
                <?php esc_html_e( '1 /', 'forest-jungle-safari' ); ?>
              </span>
              <span>
                <?php echo $forest_jungle_safari_number; ?>
              </span>
            </p>
          </div>
          <div class="carousel-inner">
            <?php for ($forest_jungle_safari_i=1; $forest_jungle_safari_i<=$forest_jungle_safari_number; $forest_jungle_safari_i++) {?>
              <div class="carousel-item <?php if($forest_jungle_safari_i == 1 ){ echo "active"; } ?>">
                <div class="carousel-caption container">
                  <div class="inner_carousel">
                    <?php if(get_theme_mod('forest_jungle_safari_tagline_title'.$forest_jungle_safari_i) != ''){ ?>
                      <h2 class="slide_splice" class=""><?php echo esc_html(get_theme_mod('forest_jungle_safari_tagline_title'.$forest_jungle_safari_i)); ?></h2>
                    <?php } ?>
                     <?php if(get_theme_mod('forest_jungle_safari_designation_text'.$forest_jungle_safari_i) != ''){ ?>
                      <p class="slide_desc"><?php echo esc_html(get_theme_mod('forest_jungle_safari_designation_text'.$forest_jungle_safari_i)); ?></p>
                    <?php } ?>
                  </div>
                </div>
                <div class="px-0">
                  <?php  $forest_jungle_safari_slider_bg = get_theme_mod('forest_jungle_safari_slider_image'.$forest_jungle_safari_i); ?>
                  <div style="background-image:url(<?php echo ($forest_jungle_safari_slider_bg) ? $forest_jungle_safari_slider_bg : '' ?>)" class="slider-bg">
                    <?php if ( get_theme_mod('forest_jungle_safari_banner_background_image_sec',true) != "" ) {?>
                      <div class="col-next">
                        <img class="slider-carousel-img text-end" src="<?php echo esc_url(get_theme_mod('forest_jungle_safari_banner_background_image_sec'.$forest_jungle_safari_i)); ?>" alt="<?php echo esc_attr(get_theme_mod('forest_jungle_safari_slide_title'.$forest_jungle_safari_i, true)); ?>" title="#slidecaption<?php echo esc_html($forest_jungle_safari_i); ?>">
                      </div>
                    <?php } ?>
                  </div>
                </div>
              </div>
            <?php } ?>
          </div>
          <?php if(get_theme_mod('forest_jungle_safari_slider_arrow_hide_show', true)){?>
            <div class="slider-nav">
              <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev">
                <i class="<?php echo esc_attr(get_theme_mod('forest_jungle_safari_slider_prev_icon','fas fa-chevron-right')); ?>"></i>
                <span class="screen-reader-text"><?php echo esc_html('Previous','forest-jungle-safari'); ?></span>
              </button>
              <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="next">
                 <i class="<?php echo esc_attr(get_theme_mod('forest_jungle_safari_slider_next_icon','fas fa-chevron-left')); ?>"></i>
                  <span class="screen-reader-text"><?php echo esc_html('Next','forest-jungle-safari'); ?></span>
              </button>
            </div>
          <?php } ?>
        </div>
      </div>
      <div class="social-bx">
        <?php if (is_active_sidebar('social-widget-banner')) : ?>
          <?php dynamic_sidebar('social-widget-banner'); ?>
        <?php else : ?>
          <!-- Default Social Icons Widgets -->
            <div class="widget">
                <ul class="custom-social-icons" >
                  <li><a href="https://facebook.com" target="_blank"><i class="fab fa-facebook"></i></a></li> 
                  <li><a href="https://instagram.com" target="_blank"><i class="fab fa-instagram"></i></a></li> 
                  <li><a href="https://twitter.com" target="_blank"><i class="fab fa-twitter"></i></a></li>                  
                  <li><a href="https://youtube.com" target="_blank"><i class="fab fa-youtube"></i></a></li>                     
                </ul>
            </div>
        <?php endif; ?>  
      </div>
    </section>
  <?php }?>
<?php do_action('forest_jungle_safari_after_slider'); ?>

<!-- Popular section -->
<div id="popular-section" class="pt-5">
  <div class="container container-class">
    <div class="popular-text text-center">
      <?php if(get_theme_mod('forest_jungle_safari_popular_heading') != ''){ ?>
        <h3 class="popular-title"><?php echo esc_html(get_theme_mod('forest_jungle_safari_popular_heading')); ?></h3>
      <?php } ?>
      <?php if(get_theme_mod('forest_jungle_safari_popular_text') != ''){ ?>
        <p class="popular-text"><?php echo esc_html(get_theme_mod('forest_jungle_safari_popular_text')); ?></p>
      <?php } ?>
    </div>
    <div class="row py-2">
    <?php
      $forest_jungle_safari_featured_post = get_theme_mod('forest_jungle_safari_claases_number');
    for ($forest_jungle_safari_i=1; $forest_jungle_safari_i <= $forest_jungle_safari_featured_post; $forest_jungle_safari_i++) {
      $forest_jungle_safari_postData=  get_theme_mod('forest_jungle_safari_services_category'.$forest_jungle_safari_i);
      if($forest_jungle_safari_postData){ ?>
        <?php
          $args = array(
            'p' => esc_html($forest_jungle_safari_postData ,'forest-jungle-safari'),
            'posts_per_page' => 1,
            'post_type' => 'post'
          );
          $query = new WP_Query( $args );
          if ( $query->have_posts() ) :
            while ( $query->have_posts() ) : $query->the_post(); ?>
            <div class="col-xl-4 col-sm-6 popular-col pb-4">
              <div class="position-relative">
                <div class="classes-inner-box">
                  <?php if(has_post_thumbnail()){ ?>
                    <?php the_post_thumbnail(); ?>
                  <?php } else {?>
                    <img src="<?php echo esc_url(get_template_directory_uri()) ?>/assets/images/post-image.png" alt="<?php echo esc_attr('Post Image', 'forest-jungle-safari'); ?>">
                  <?php }?>
                </div>
                <div class="popular-content wow bounceInLeft delay-1000">
                  <h4 class=""><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h4>
                  <div class="popular-content-sec d-flex align-items-center ">
                    <p class="mb-0"><?php $forest_jungle_safari_excerpt = get_the_excerpt(); echo esc_html( forest_jungle_safari_string_limit_words( $forest_jungle_safari_excerpt, esc_attr(get_theme_mod('forest_jungle_safari_slider_excerpt_number_post','15')))); ?> <?php echo esc_html(get_theme_mod('forest_jungle_safari_blog_excerpt_suffix1',''));?>
                    </p>
                    <div class="price-section">
                      <?php if( get_theme_mod('forest_jungle_safari_user'.$forest_jungle_safari_i) != ''){ ?>
                        <div class="user-meta-fields">
                          <span class="user-text"><?php echo esc_html(get_theme_mod('forest_jungle_safari_user'.$forest_jungle_safari_i));?></span>
                        </div>
                      <?php }?>
                    </div>
                  </div>
                </div>
                <div class="read-more-arrow">
                  <a class="p-3" href="<?php the_permalink(); ?>">
                    <?php echo esc_html(get_theme_mod('forest_jungle_safari_service_button_label'.$forest_jungle_safari_i, __('Read More', 'forest-jungle-safari'))); ?>
                    <span class="screen-reader-text">
                      <?php echo esc_html(get_theme_mod('forest_jungle_safari_service_button_label'.$forest_jungle_safari_i, __('Read More', 'forest-jungle-safari'))); ?>
                    </span>
                  </a>
                </div>
              </div>
            </div>
          <?php endwhile;
            wp_reset_postdata();
          endif; ?>
      <?php }
    } ?>
  </div>
  </div>
</div>

<!-- Special Services Section -->
  <?php if( get_theme_mod('forest_jungle_safari_featured_section',true) != ''){ ?>
    <section id="special-services" class=" pt-3">
      <?php if( get_theme_mod('forest_jungle_safari_featured_section',true) != ''){ ?>
        <section id="special-services" class="pt-3">
          <div class="container">
            <div class="special-text text-center">
              <?php if(get_theme_mod('forest_jungle_safari_special_heading') != ''){ ?>
                <h3 class="special-title"><?php echo esc_html(get_theme_mod('forest_jungle_safari_special_heading')); ?></h3>
              <?php } ?>
              <?php if(get_theme_mod('forest_jungle_safari_special_text') != ''){ ?>
                <p class="special-text"><?php echo esc_html(get_theme_mod('forest_jungle_safari_special_text')); ?></p>
              <?php } ?>
            </div>
              <?php
                $forest_jungle_safari_number = get_theme_mod('forest_jungle_safari_services_number');
                if ($forest_jungle_safari_number != '') { ?>
                <div id="sponsor-section" class="pt-3 wow bounceInLeft delay-1000">
                  <div class="row">
                    <?php for ($forest_jungle_safari_i = 1; $forest_jungle_safari_i <= $forest_jungle_safari_number; $forest_jungle_safari_i++) { ?>
                      <div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 col-12">
                        <div class="inner-box">
                          <div class="counter d-flex justify-content-space-between">
                            <i class="<?php echo esc_attr(get_theme_mod('forest_jungle_safari_services_icon'.$forest_jungle_safari_i,'fa-solid fa-camera')); ?>"></i>
                            <span class="count-num"><?php echo sprintf('%02d', $forest_jungle_safari_i); ?></span>
                          </div>
                          <?php if (get_theme_mod('forest_jungle_safari_client_tagline_title' . $forest_jungle_safari_i) != '') { ?>
                            <h4 class="mb-2 mt-3"><?php echo esc_html(get_theme_mod('forest_jungle_safari_client_tagline_title' . $forest_jungle_safari_i)); ?></h4>
                          <?php } ?>
                          <?php if (get_theme_mod('forest_jungle_safari_client_text' . $forest_jungle_safari_i) != '') { ?>
                            <p class="client-para"><?php echo esc_html(get_theme_mod('forest_jungle_safari_client_text' . $forest_jungle_safari_i)); ?></p>
                          <?php } ?>
                        </div>
                      </div>
                    <?php } ?>
                  </div>
                </div>
              <?php } ?>
          </div>
        </section>
      <?php }?>
    </section>
  <?php }?>
<?php do_action( 'forest_jungle_safari_after_service' ); ?>

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

<?php get_footer(); ?>