<?php
/**
 * Template part for displaying slider section
 *
 * @package Luxury Hotels
 * @subpackage luxury_hotels
 */

?>
<?php $luxury_hotels_static_image = get_template_directory_uri() . '/assets/images/slider-img.png'; ?>
<?php if( get_theme_mod( 'luxury_hotels_slider_arrows', true) != '') { ?>

<section id="slider">
  <div class="owl-carousel">
      <?php $luxury_hotels_slide_pages = array();
        for ( $luxury_hotels_count = 1; $luxury_hotels_count <= 4; $luxury_hotels_count++ ) {
          $luxury_hotels_mod = intval( get_theme_mod( 'luxury_hotels_slider_page' . $luxury_hotels_count ));
          if ( 'page-none-selected' != $luxury_hotels_mod ) {
            $luxury_hotels_slide_pages[] = $luxury_hotels_mod;
          }
        }
        if( !empty($luxury_hotels_slide_pages) ) :
          $luxury_hotels_args = array(
            'post_type' => 'page',
            'post__in' => $luxury_hotels_slide_pages,
            'orderby' => 'post__in'
          );
          $luxury_hotels_query = new WP_Query( $luxury_hotels_args );
          if ( $luxury_hotels_query->have_posts() ) :
            $i = 1;
      ?>
      <?php  while ( $luxury_hotels_query->have_posts() ) : $luxury_hotels_query->the_post(); ?>
      <div class="slide-box">
          <div class="inner_content">
            <?php if( get_theme_mod( 'luxury_hotels_slider_short_heading' ) != '' ) { ?>
              <p class="slider-top"><?php echo esc_html( get_theme_mod( 'luxury_hotels_slider_short_heading','' ) ); ?></p>
            <?php } ?>
              <?php if (get_theme_mod('luxury_hotels_show_slider_title', true)) : ?>
                <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
              <?php endif; ?>
              <?php if (get_theme_mod('luxury_hotels_show_slider_content', true)) : ?>
                <p><?php $luxury_hotels_excerpt = get_the_excerpt(); echo esc_html( luxury_hotels_string_limit_words( $luxury_hotels_excerpt, esc_attr(get_theme_mod('luxury_hotels_slider_excerpt_length','40')))); ?></p>
              <?php endif; ?>
              <div class="more-btn">
                    <?php if( get_theme_mod( 'luxury_hotels_slider_button_link'.$i ) ) { ?>
                      <a class="btn-1" href="<?php echo esc_url( get_theme_mod('luxury_hotels_slider_button_link' .$i) ); ?>" target="_blank"><?php esc_html_e('Know More About Hotel','luxury-hotels'); ?><i class="fas fa-play"></i></a>
                    <?php }?>          
              </div>
          </div>
          <div class="img-box">
            <?php if(has_post_thumbnail()){ ?>
              <img src="<?php the_post_thumbnail_url('full'); ?>"/> <?php } else {echo ('<img src="'.esc_url( $luxury_hotels_static_image ).'">'); } ?>
          </div>
      </div>
      <?php $i++; endwhile;
          wp_reset_postdata();?>
      <?php else : ?>
          <div class="no-postfound"></div>
        <?php endif;
      endif;?>
  </div>
  <div class="clearfix"></div>
</section>

<?php } ?>
