<?php
/**
 * Template part for displaying slider section
 *
 * @package Online Startup Agency
 * @subpackage online_startup_agency
 */

?>
<?php $online_startup_agency_static_image = get_stylesheet_directory_uri() . '/assets/images/slider-img.png'; ?>
<?php if (get_theme_mod('online_startup_agency_slider_arrows', true) != '') : ?>

<section id="slider" class="mb-5 mt-5 mt-md-0">
  <div class="container">
    <div id="owl-carousel" class="owl-carousel">
      <?php
      $online_startup_agency_slide_pages = array();
      for ($online_startup_agency_count = 1; $online_startup_agency_count <= 3; $online_startup_agency_count++) {
          $online_startup_agency_mod = intval(get_theme_mod('online_startup_agency_slider_page' . $online_startup_agency_count));
          if ('page-none-selected' != $online_startup_agency_mod) {
              $online_startup_agency_slide_pages[] = $online_startup_agency_mod;
          }
      }
      if (!empty($online_startup_agency_slide_pages)) :
          $online_startup_agency_args = array(
              'post_type' => 'page',
              'post__in' => $online_startup_agency_slide_pages,
              'orderby' => 'post__in'
          );
          $online_startup_agency_query = new WP_Query($online_startup_agency_args);
          if ($online_startup_agency_query->have_posts()) :
              while ($online_startup_agency_query->have_posts()) : $online_startup_agency_query->the_post(); ?>
                  <div class="item">
                      <div class="slider-border">
                        <?php if (has_post_thumbnail()) { ?>
                            <img src="<?php the_post_thumbnail_url('full'); ?>" />
                        <?php } else { ?>
                            <img src="<?php echo esc_url($online_startup_agency_static_image); ?>" />
                        <?php } ?>
                      </div>
                      <div class="carousel-caption">
                          <div class="inner_carousel">
                              <?php if (get_theme_mod('online_startup_agency_slider_short_heading') != '') { ?>
                                  <p class="slidetop-text"><?php echo esc_html(get_theme_mod('online_startup_agency_slider_short_heading', '')); ?></p>
                              <?php } ?>
                              <?php if (get_theme_mod('online_startup_agency_show_slider_title', true)) : ?>
                                  <h1 class="custom-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                              <?php endif; ?>
                              <?php if (get_theme_mod('online_startup_agency_show_slider_content', true)) : ?>
                                  <p class="mb-2 slider-content"><?php echo wp_trim_words( get_the_content(),15 );?></p>
                              <?php endif; ?>
                              <div class="more-btn mt-4">
                                  <a href="<?php the_permalink(); ?>" class="text-capitalize me-2 mb-3 slider-btn1"><?php esc_html_e('Order Now', 'online-startup-agency'); ?><i class="fa-solid fa-arrow-right ms-2"></i></a>

                                  <?php if(get_theme_mod('online_startup_agency_product_btn_text1','MAKE AN APPOINTMENT') != '' && get_theme_mod('online_startup_agency_product_btn_link1')){ ?>
                                    <a class="text-uppercase slider-btn2" href="<?php echo esc_url(get_theme_mod('online_startup_agency_product_btn_link1')); ?>"><?php echo esc_html(get_theme_mod('online_startup_agency_product_btn_text1','LEARN MOIRE')); ?><i class="fa-solid fa-arrow-right ms-2"></i><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('online_startup_agency_product_btn_text1','LEARN MOIRE')); ?></span></a>
                                  <?php }?>
                              </div>
                          </div>
                      </div>
                  </div>
              <?php endwhile;
              wp_reset_postdata(); ?>
          <?php else : ?>
              <div class="no-postfound"></div>
          <?php endif;
      endif; ?>
    </div>
  <!-- custom pagination -->
    <div class="custom-pagination">
        <span class="pagination-item active" data-slide="<?php echo esc_attr( 0 ); ?>">
            <?php echo esc_html__( '01', 'online-startup-agency' ); ?>
        </span>
        <span class="pagination-item" data-slide="<?php echo esc_attr( 1 ); ?>">
            <?php echo esc_html__( '02', 'online-startup-agency' ); ?>
        </span>
        <span class="pagination-item" data-slide="<?php echo esc_attr( 2 ); ?>">
            <?php echo esc_html__( '03', 'online-startup-agency' ); ?>
        </span>
    </div>
  </div>

</section>
<?php endif; ?>
