<?php
/**
 * Template part for displaying slider section
 *
 * @package Window Blinds Repair
 * @subpackage window_blinds_repair
 */

?>
<?php $window_blinds_repair_static_image = get_stylesheet_directory_uri() . '/assets/images/header_img.png'; ?>
<?php if (get_theme_mod('window_blinds_repair_slider_arrows', true) != '') : ?>

<section id="slider">
  <div id="owl-carousel" class="owl-carousel">
    <?php
    $window_blinds_repair_slide_pages = array();
    for ($window_blinds_repair_count = 1; $window_blinds_repair_count <= 4; $window_blinds_repair_count++) {
        $window_blinds_repair_mod = intval(get_theme_mod('window_blinds_repair_slider_page' . $window_blinds_repair_count));
        if ('page-none-selected' != $window_blinds_repair_mod) {
            $window_blinds_repair_slide_pages[] = $window_blinds_repair_mod;
        }
    }
    if (!empty($window_blinds_repair_slide_pages)) :
        $window_blinds_repair_args = array(
            'post_type' => 'page',
            'post__in' => $window_blinds_repair_slide_pages,
            'orderby' => 'post__in'
        );
        $window_blinds_repair_query = new WP_Query($window_blinds_repair_args);
        if ($window_blinds_repair_query->have_posts()) :
            while ($window_blinds_repair_query->have_posts()) : $window_blinds_repair_query->the_post(); ?>
                <div class="item">
                    <?php if (has_post_thumbnail()) { ?>
                        <img src="<?php the_post_thumbnail_url('full'); ?>" />
                    <?php } else { ?>
                        <img src="<?php echo esc_url($window_blinds_repair_static_image); ?>" />
                    <?php } ?>
                    <div class="carousel-caption">
                        <div class="inner_carousel">
                            <?php if (get_theme_mod('window_blinds_repair_slider_short_heading') != '') { ?>
                                <p class="slidetop-text"><?php echo esc_html(get_theme_mod('window_blinds_repair_slider_short_heading', '')); ?></p>
                            <?php } ?>
                            <?php if (get_theme_mod('window_blinds_repair_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('window_blinds_repair_show_slider_content', true)) : ?>
                                <p class="mb-2"><?php echo wp_trim_words( get_the_content(),30 );?></p>
                            <?php endif; ?>
                            <div class="more-btn mt-4">
                                <a href="<?php the_permalink(); ?>" class="text-uppercase me-2 mb-3 slider-btn1"><?php esc_html_e('Learn More', 'window-blinds-repair'); ?></a>
                                <?php if(get_theme_mod('window_blinds_repair_product_btn_text1','MAKE AN APPOINTMENT') != '' && get_theme_mod('window_blinds_repair_product_btn_link1')){ ?>
                                  <a class="text-uppercase slider-btn2" href="<?php echo esc_url(get_theme_mod('window_blinds_repair_product_btn_link1')); ?>"><?php echo esc_html(get_theme_mod('window_blinds_repair_product_btn_text1','MAKE AN APPOINTMENT')); ?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('window_blinds_repair_product_btn_text1','MAKE AN APPOINTMENT')); ?></span></a>
                                <?php }?>
                            </div>
                        </div>
                    </div>
                </div>
            <?php endwhile;
            wp_reset_postdata(); ?>
        <?php else : ?>
            <div class="no-postfound"></div>
        <?php endif;
    endif; ?>
  </div>
</section>
<?php endif; ?>
