<?php
/**
 * Template Name: Home Custom Page
 */
get_header(); ?>

<main id="main" role="main">
  <?php do_action( 'tafri_travel_blog_before_slider' ); ?>

  <?php if( get_theme_mod('tafri_travel_blog_slider_arrows', false) != '' || get_theme_mod( 'tafri_travel_blog_enable_disable_slider', true) != ''){ ?>
    <div class="<?php if( get_theme_mod('tafri_travel_blog_slider_width_options', 'Full Width') == 'Container Width'){ ?>container <?php }?>">
    <section id="slider">
      <div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="carousel" data-interval="<?php echo esc_attr(get_theme_mod('tafri_travel_blog_slider_speed', 3000)); ?>">
        <?php $tafri_travel_blog_slider_pages = array();
          for ( $count = 1; $count <= 4; $count++ ) {
            $mod = intval( get_theme_mod( 'tafri_travel_blog_slide_page' . $count ));
            if ( 'page-none-selected' != $mod ) {
              $tafri_travel_blog_slider_pages[] = $mod;
            }
          }
          if( !empty($tafri_travel_blog_slider_pages) ) :
          $args = array(
            'post_type' => 'page',
            'post__in' => $tafri_travel_blog_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"';}?>>
            <?php if(has_post_thumbnail()){
                 the_post_thumbnail();
                } else{?>
                  <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/slider.png" alt="" />
            <?php } ?>
            <div class="carousel-caption">
              <div class="inner_carousel">
                <?php if( get_theme_mod('tafri_travel_blog_slider_title',true) != ''){ ?>
                  <h1 class="text-capitalize"><?php the_title();?></h1>
                <?php } ?>
                <?php if( get_theme_mod('tafri_travel_blog_slider_content',true) != ''){ ?>
                  <p><?php $tafri_travel_blog_excerpt = get_the_excerpt(); echo esc_html( tafri_travel_blog_string_limit_words( $tafri_travel_blog_excerpt, esc_attr(get_theme_mod('tafri_travel_blog_slider_excerpt_number','20')))); ?></p>
                <?php } ?>
                <?php if (get_theme_mod( 'tafri_travel_blog_slider_button',true) != '' || get_theme_mod( 'tafri_travel_blog_show_hide_slider_button',true) != ''){ ?>
                  <?php if( get_theme_mod('tafri_travel_blog_slider_button_text','View All Tours') != ''){ ?>
                    <div class ="readbutton mt-md-2">
                      <a href="<?php echo esc_url( get_theme_mod('tafri_travel_blog_slider_button_text_url','') );?>"><?php echo esc_html(get_theme_mod('tafri_travel_blog_slider_button_text','View All Tours'));?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('tafri_travel_blog_slider_button_text','View All Tours'));?></span></a>
                    </div>
                  <?php } ?>
                <?php } ?>
              </div>
              <div class="social-icons mt-4 text-md-start text-center">
                <?php if(get_theme_mod('tafri_travel_blog_facebook_url') != ''){?>
                  <a href="<?php echo esc_url(get_theme_mod('tafri_travel_blog_facebook_url')); ?>" target="_blank"><i class="fab fa-facebook-f"></i><span class="screen-reader-text"><?php echo esc_html__('Facebook', 'tafri-travel-blog'); ?></span></a>
                <?php }?>
                <?php if(get_theme_mod('tafri_travel_blog_twitter_url') != ''){?>
                  <a href="<?php echo esc_url(get_theme_mod('tafri_travel_blog_twitter_url')); ?>" target="_blank" ><i class="fab fa-twitter"></i><span class="screen-reader-text"><?php echo esc_html__('Twitter', 'tafri-travel-blog'); ?></span></a>
                <?php }?>
                <?php if(get_theme_mod('tafri_travel_blog_instagram_url') != ''){?>
                  <a href="<?php echo esc_url(get_theme_mod('tafri_travel_blog_instagram_url')); ?>" target="_blank" ><i class="fab fa-instagram"></i><span class="screen-reader-text"><?php echo esc_html__('Instagram', 'tafri-travel-blog'); ?></span></a>
                <?php }?>
                <?php if(get_theme_mod('tafri_travel_blog_linkedin_url') != ''){?>
                  <a href="<?php echo esc_url(get_theme_mod('tafri_travel_blog_linkedin_url')); ?>" target="_blank" ><i class="fab fa-linkedin-in"></i><span class="screen-reader-text"><?php echo esc_html__('Linkedin', 'tafri-travel-blog'); ?></span></a>
                <?php }?>
              </div>
            </div>
          </div>
          <?php $i++; endwhile;
          wp_reset_postdata();?>
        </div>
        <?php else : ?>
        <div class="no-postfound"></div>
          <?php endif;
        endif;?>
        <div class="slider-icon">
          <?php  while ( $query->have_posts() ) : $query->the_post(); ?>
            <div class="slider-icon-image">
              <?php the_post_thumbnail(); ?>
            </div>
          <?php endwhile;
          wp_reset_postdata();?>
        </div>
        <a class="carousel-control-prev" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev" role="button">
          <span class="carousel-control-prev-icon" aria-hidden="true"><i class="fas fa-chevron-left"></i></span>
          <span class="screen-reader-text"><?php esc_html_e( 'Previous','tafri-travel-blog' );?></span>
        </a>
        <a class="carousel-control-next" data-bs-target="#carouselExampleCaptions" data-bs-slide="next" role="button">
          <span class="carousel-control-next-icon" aria-hidden="true"><i class="fas fa-chevron-right"></i></span>
          <span class="screen-reader-text"><?php esc_html_e( 'Next','tafri-travel-blog' );?></span>
        </a>
      </div>
      <div class="clearfix"></div>
    </section>
  <?php }?>

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

  <?php if( get_theme_mod('tafri_travel_blog_section_title') != ''|| get_theme_mod('tafri_travel_blog_section_text') != '' || get_theme_mod('tafri_travel_blog_tour_category') != ''){ ?>
    <section id="tour-section" class="py-5">
      <div class="container">
        <?php if( get_theme_mod('tafri_travel_blog_section_title') != ''){ ?>
          <h2><?php echo esc_html(get_theme_mod('tafri_travel_blog_section_title')); ?></h2>
        <?php }?>
        <?php if( get_theme_mod('tafri_travel_blog_section_text') != ''){ ?>
          <p><?php echo esc_html(get_theme_mod('tafri_travel_blog_section_text')); ?></p>
        <?php }?>
        <div class="row mt-5">
          <?php
            $tafri_travel_blog_catData=  get_theme_mod('tafri_travel_blog_tour_category');
            if($tafri_travel_blog_catData){
            $page_query = new WP_Query(array( 'category_name' => esc_html( $tafri_travel_blog_catData ,'tafri-travel-blog')));?>
            <?php while( $page_query->have_posts() ) : $page_query->the_post(); ?>
              <div class="col-lg-4 col-md-6">
                <div class="tour-box mb-4">
                  <?php $tafri_travel_blog_price = get_post_meta($post->ID, 'tafri_travel_blog_price', true); ?>
                  <?php if(has_post_thumbnail()) { ?>
                    <div class="tour-img">
                      <?php the_post_thumbnail(); ?>
                      <?php if ($tafri_travel_blog_price != ''){?>
                        <div class="tour-price">
                          <span><?php echo esc_html($tafri_travel_blog_price); ?></span>
                        </div>
                      <?php }?>
                    </div>
                  <?php }?>
                  <div class="tour-content">
                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    <div class="prices-box">
                      <div class="row">
                        <div class="col-lg-7 col-md-7 col-7 align-self-center">
                          <?php if( get_post_meta($post->ID, 'tafri_travel_blog_duration', true) ) {?>
                            <span><?php echo esc_html(get_post_meta($post->ID,'tafri_travel_blog_duration',true)); ?></span>
                          <?php }?>
                        </div>
                        <div class="col-lg-5 col-md-5 col-5 align-self-center">
                          <div class ="tour-btn text-end">
                            <a href="<?php the_permalink(); ?>"><?php echo esc_html__('Book Now', 'tafri-travel-blog'); ?><span class="screen-reader-text"><?php echo esc_html__('Book Now', 'tafri-travel-blog'); ?></span></a>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            <?php endwhile;
            wp_reset_postdata();
          } ?>
        </div>
      </div>
    </section>
  <?php }?>

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

  <div class="container text">
    <?php while ( have_posts() ) : the_post();?>
      <?php the_content(); ?>
    <?php endwhile; // End of the loop.
    wp_reset_postdata(); ?>
  </div>
</main>

<?php get_footer(); ?>
