<?php 
$expert_sports_coach_slider = get_theme_mod('expert_sports_coach_slider_setting', true);

if ($expert_sports_coach_slider == '1') :
?>

<section id="slider">
    <div id="owl-carousel" class="owl-carousel">
        <?php

        $expert_sports_coach_slide_pages = array();
        for ($expert_sports_coach_count = 1; $expert_sports_coach_count <= 3; $expert_sports_coach_count++) {
            $expert_sports_coach_mod = intval(get_theme_mod('expert_sports_coach_slider_page' . $expert_sports_coach_count));
        
            // Check that the value is valid and not the placeholder value 'page-none-selected'
            if ('page-none-selected' !== $expert_sports_coach_mod && $expert_sports_coach_mod > 0) {
                $expert_sports_coach_slide_pages[] = $expert_sports_coach_mod;
            }
        }

        if (!empty($expert_sports_coach_slide_pages)) :
            $expert_sports_coach_args = array(
                'post_type' => 'page',
                'post__in' => $expert_sports_coach_slide_pages,
                'orderby' => 'post__in'
            );
            $expert_sports_coach_query = new WP_Query($expert_sports_coach_args);
            if ($expert_sports_coach_query->have_posts()) :
                while ($expert_sports_coach_query->have_posts()) : $expert_sports_coach_query->the_post(); ?>
                    <div class="item">
                        <?php if (has_post_thumbnail()) { ?>
                            <img src="<?php echo esc_url(get_the_post_thumbnail_url(get_the_ID(), 'full')); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" />
                        <?php } else { ?>
                            <div class="slider-color-box"></div>
                        <?php } ?>

                        <div class="container">
                            <div class="row">
                                <div class="col-lg-6 col-md-6 col-8">
                                    <div class="carousel-caption">
                                        <div class="inner_carousel wow fadeInUp" data-wow-delay="0.5s">
                                            <?php if (get_theme_mod('expert_sports_coach_slider_short_heading') != '') { ?>
                                                <p class="slidetop-text mb-3"><?php echo esc_html(get_theme_mod('expert_sports_coach_slider_short_heading', '')); ?></p>
                                            <?php } ?>
                                            <h1 class="custom-title mb-2"><a href="<?php the_permalink(); ?>" class="title-link"><?php the_title(); ?></a></h1>
                                            <p class="mb-2"><?php echo esc_html(wp_trim_words(get_the_content(), 25)); ?></p>
                                            <div class="more-btn mt-4">
                                                <?php if ( get_theme_mod('expert_sports_coach_slider_btn_text','true') != "" || get_theme_mod('expert_sports_coach_slider_btn_link') != '') { ?>
                                                    <a class="text-capitalize mb-3 slider-btn1" href="<?php echo esc_url(get_theme_mod('expert_sports_coach_slider_btn_link')!= '') ? esc_url(get_theme_mod('expert_sports_coach_slider_btn_link')) : esc_url(get_permalink()); ?>">
                                                    <?php echo esc_html(get_theme_mod('expert_sports_coach_slider_btn_text',__('Join Our Club','expert-sports-coach'))); ?>
                                                  </a>
                                                <?php }?>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-6 col-4 social-box">
                                    <div class="text-lg-end text-md-center text-center align-self-center social-area mb-md-0 ps-lg-2">
                                        <?php
                                        $expert_sports_coach_social_media_youtube = get_theme_mod('expert_sports_coach_social_media_youtube');
                                        $expert_sports_coach_social_media_instagram = get_theme_mod('expert_sports_coach_social_media_instagram');
                                        $expert_sports_coach_social_media_twitter = get_theme_mod('expert_sports_coach_social_media_twitter');
                                        $expert_sports_coach_social_media_pinterest = get_theme_mod('expert_sports_coach_social_media_pinterest');
                                        ?>
                                        <?php if ($expert_sports_coach_social_media_youtube != '') { ?>
                                            <a target="_blank" href="<?php echo esc_url($expert_sports_coach_social_media_youtube); ?>"><i class="fab fa-youtube"></i><span class="screen-reader-text"><?php esc_html_e('YouTube', 'expert-sports-coach'); ?></span></a>
                                        <?php } ?>
                                        <?php if ($expert_sports_coach_social_media_instagram != '') { ?>
                                            <a target="_blank" href="<?php echo esc_url($expert_sports_coach_social_media_instagram); ?>"><i class="fab fa-instagram"></i><span class="screen-reader-text"><?php esc_html_e('Instagram', 'expert-sports-coach'); ?></span></a>
                                        <?php } ?>
                                        <?php if ($expert_sports_coach_social_media_twitter != '') { ?>
                                            <a target="_blank" href="<?php echo esc_url($expert_sports_coach_social_media_twitter); ?>"><i class="fab fa-twitter"></i><span class="screen-reader-text"><?php esc_html_e('Twitter', 'expert-sports-coach'); ?></span></a>
                                        <?php } ?>
                                        <?php if ($expert_sports_coach_social_media_pinterest != '') { ?>
                                            <a target="_blank" href="<?php echo esc_url($expert_sports_coach_social_media_pinterest); ?>"><i class="fab fa-pinterest-p"></i><span class="screen-reader-text"><?php esc_html_e('Pinterest', 'expert-sports-coach'); ?></span></a>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endwhile;
                wp_reset_postdata(); ?>
            <?php else : ?>
                <div class="no-postfound"></div>
            <?php endif;
        endif; ?>
    </div>
</section>
<?php endif; ?>