<?php 
$expert_finance_manager_slider_arrows = get_theme_mod('expert_finance_manager_slider_arrows',false);
?>
<?php if ($expert_finance_manager_slider_arrows) : ?>
  <section id="slider">
    <div class="owl-carousel owl-theme">
      <?php 
      $expert_finance_manager_slide_pages = array();
      for ($expert_finance_manager_count = 1; $expert_finance_manager_count <= 3; $expert_finance_manager_count++) {
        $mod = absint(get_theme_mod('expert_finance_manager_slider_page' . $expert_finance_manager_count));
        if ($mod != 0) {
          $expert_finance_manager_slide_pages[] = $mod;
        }
      }
      if (!empty($expert_finance_manager_slide_pages)) :
        $expert_finance_manager_args = array(
          'post_type' => 'page',
          'post__in' => $expert_finance_manager_slide_pages,
          'orderby' => 'post__in'
        );
        $expert_finance_manager_query = new WP_Query($expert_finance_manager_args);
        if ($expert_finance_manager_query->have_posts()) :
          while ($expert_finance_manager_query->have_posts()) : $expert_finance_manager_query->the_post(); ?>
            <div class="container">
              <div class="item">
                <div class="row">
                  <div class="col-lg-6 col-md-6 col-12 slider-content-col align-self-center wow fadeInRight" data-wow-delay="0.5s">
                    <div class="carousel-captions">
                      <div class="inner_carousel">
                        <h1 class="mb-2">
                            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                        </h1>
                        <p class="mb-2 slider-content"><?php echo wp_kses_post(wp_trim_words(get_the_content(), 50)); ?></p>
                        <div class="slider-mainbtn mt-md-4 mt-3 mb-3">
                            <!-- First button -->
                            <span class="slide-btn1">
                                <a href="<?php the_permalink(); ?>" class="btn-text me-md-3 mb-2">
                                    <?php echo esc_html__('Get Started', 'expert-finance-manager'); ?>
                                </a>
                            </span>
                            <!-- Second button  -->
                            <span class="slide-btn2">
                                <?php
                                $expert_finance_manager_slider_btn_text = get_theme_mod('expert_finance_manager_slider_btn_text', 'Contact Us');
                                $expert_finance_manager_slider_btn_link = get_theme_mod('expert_finance_manager_slider_btn_link','#');

                                if (!empty($expert_finance_manager_slider_btn_text) && !empty($expert_finance_manager_slider_btn_link)) { ?>
                                    <a href="<?php echo esc_url($expert_finance_manager_slider_btn_link); ?>" class="btn-text">
                                        <?php echo esc_html($expert_finance_manager_slider_btn_text); ?>
                                    </a>
                                <?php } ?>
                            </span>
                        </div>
                      </div>
                    </div>
                  </div>
                  <div class="col-lg-6 col-md-6 col-12 slider-img-col align-self-center wow fadeInLeft" data-wow-delay="0.5s">
                    <?php if (has_post_thumbnail()) : ?>
                        <img src="<?php the_post_thumbnail_url('full'); ?>" alt="<?php the_title_attribute(); ?>" />
                    <?php else : ?>
                        <img src="<?php echo esc_url(get_template_directory_uri() . '/assets/images/default-slider.png'); ?>" alt="<?php the_title_attribute(); ?>" />
                    <?php endif; ?>
                  </div>
                </div>
              </div>
            </div>
          <?php endwhile;
          wp_reset_postdata();
        else : ?>
          <div class="no-postfound"><?php esc_html_e('No posts found', 'expert-finance-manager'); ?></div>
        <?php endif;
      endif; ?>
    </div>
    <div class="clearfix"></div>
  </section>
<?php endif; ?>
