<?php 
$led_tv_slider = get_theme_mod('led_tv_slider_setting', true);
  
if ($led_tv_slider !== false) {
?>
<section id="slider-section" class="slider-area">
  <div id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel">
    <?php 
	    $led_tv_pages = array();
	    for ($led_tv_count = 1; $led_tv_count <= 3; $led_tv_count++) {
	        $led_tv_mod = intval(get_theme_mod('led_tv_slider' . $led_tv_count));
	        if ($led_tv_mod !== 0 && $led_tv_mod !== '') {
	            $led_tv_pages[] = $led_tv_mod;
	        }
	    }
	    if (!empty($led_tv_pages)) :
	        $args = array(
	            'post_type' => 'page',
	            'post__in' => $led_tv_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 echo ($i == 1) ? 'class="carousel-item active"' : 'class="carousel-item"'; ?>>
          <?php if (has_post_thumbnail()) : ?>
            <img src="<?php the_post_thumbnail_url('full'); ?>" class="d-block w-100" alt="<?php the_title_attribute(); ?>">
          <?php else : ?>
            <div class="slider-color-box"></div>
          <?php endif; ?>
          <div class="carousel-caption">
            <div class="inner_carousel wow fadeInUp" data-wow-delay="0.5s">
              <?php
              $led_tv_slider_text = get_theme_mod('led_tv_slider_text');
              if ($led_tv_slider_text) : ?>
              <div class="border-heading">
                <h5 class="mb-3"><?php echo esc_html(apply_filters('led_tv_topheader', $led_tv_slider_text)); ?></h5>
              </div>
              <?php endif; ?>
              <h2><?php the_title(); ?></h2>
              <?php
              $led_tv_slider_text_one = get_theme_mod('led_tv_slider_text_one');
              if ($led_tv_slider_text_one) : ?>
              <h4 class="mb-3"><?php echo esc_html(apply_filters('led_tv_topheader', $led_tv_slider_text_one)); ?></h4>
              <?php endif; ?>
              <p><?php echo esc_html(wp_trim_words(get_the_content(), '25')); ?></p>
              <div class="read-btn">
                <a href="<?php the_permalink(); ?>"><i class="fas fa-calendar-alt me-2"></i><?php echo esc_html__('MAKE AN APPOINTMENT', 'led-tv'); ?></a>
              </div>
            </div>
          </div>
        </div>
      <?php $i++;
          endwhile;
          wp_reset_postdata(); ?>
    </div>
    <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleInterval" id="prev" data-bs-slide="prev">
      <i class="fas fa-angle-left" aria-hidden="true"></i>
      <span class="screen-reader-text"><?php echo esc_html__('Previous', 'led-tv'); ?></span>
    </button>
    <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="next" id="next">
      <i class="fas fa-angle-right" aria-hidden="true"></i>
      <span class="screen-reader-text"><?php echo esc_html__('Next', 'led-tv'); ?></span>
    </button>
    <?php endif;
    endif; ?>
  </div>
</section>
<?php } ?>
