<?php
/**
 * Banner Section
 * 
 * @package esports_blog
 */

$esports_blog_slider = get_theme_mod( 'esports_blog_slider_setting', false );
$esports_blog_args   = array(
  'post_type'      => 'post',
  'post_status'    => 'publish',
  'category_name'  => get_theme_mod( 'esports_blog_blog_slide_category' ),
  'posts_per_page' => 3,
); ?>

<?php if ( $esports_blog_slider ) { ?>
  <div class="banner-main">
    <div class="test">
      <div class="container">
        <div class="row">
          <!-- Static Text Section -->
          <div class="col-lg-6 col-md-12">
            <div class="banner_box">
              <?php if ( get_theme_mod('esports_blog_slider_text_extra') ) : ?>
                <h5><?php echo esc_html(get_theme_mod('esports_blog_slider_text_extra')); ?></h5>
              <?php endif; ?>
              <?php if ( get_theme_mod('esports_blog_slider_banner_heading') ) : ?>
                <h3><?php echo esc_html(get_theme_mod('esports_blog_slider_banner_heading')); ?></h3>
              <?php endif; ?>
              <?php if ( get_theme_mod('esports_blog_slider_banner_content') ) : ?>
                <p><?php echo esc_html(get_theme_mod('esports_blog_slider_banner_content')); ?></p>
              <?php endif; ?>

              <div class="slide-btn-green mt-4">
                <?php $esports_blog_slider_button_url = get_theme_mod( 'esports_blog_slider_btn_url' ); ?>
                <a href="<?php echo esc_url($esports_blog_slider_button_url); ?>">
                  <?php esc_html_e('Discover More', 'esports-blog'); ?>
                </a>
                <i class="fas fa-arrow-right"></i>
              </div>
            </div>
          </div>

          <!-- Owl Carousel only for images -->
          <div class="col-lg-6 col-md-12 banner_inner_box_img ss position-relative p-0">
            <div class="owl-carousel">
              <?php 
              $esports_blog_arr_posts = new WP_Query( $esports_blog_args );
              if ( $esports_blog_arr_posts->have_posts() ) :
                while ( $esports_blog_arr_posts->have_posts() ) :
                  $esports_blog_arr_posts->the_post(); ?>
                  
                  <div class="single-slide wow zoomIn delay-1000" data-wow-duration="2s">
                    <?php if ( has_post_thumbnail() ) : ?>
                      <?php the_post_thumbnail(); ?>
                    <?php else : ?>
                      <img src="<?php echo get_stylesheet_directory_uri() . '/images/default-header.png'; ?>" alt="<?php esc_attr_e('Default Image', 'esports-blog'); ?>">
                    <?php endif; ?>
                    <div class="img-content">
                      <h3 class="my-1">
                        <a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php the_title(); ?></a>
                      </h3>
                      <p class="mb-0"><?php echo wp_trim_words(get_the_content(), 10); ?></p>
                    </div>
                  </div>

                <?php endwhile;
                wp_reset_postdata();
              endif; ?>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <!-- Counter Section -->
  <div class="sliderbox-sec">
    <?php if ( get_theme_mod('esports_blog_total_no_satisfied_counter_no_1') != '' || get_theme_mod('esports_blog_total_no_satisfied_counter_text_1') != '' ) { ?>
      <div class="customer-counter">
        <div class="customer-no"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_no_1', '')); ?></div>
        <div class="centers-text"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_text_1', '')); ?></div>
      </div>
    <?php } ?>
    <?php if ( get_theme_mod('esports_blog_total_no_satisfied_counter_no_2') != '' || get_theme_mod('esports_blog_total_no_satisfied_counter_text_2') != '' ) { ?>
      <div class="customer-counter">
        <div class="customer-no"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_no_2', '')); ?></div>
        <div class="centers-text"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_text_2', '')); ?></div>
      </div>
    <?php } ?>
    <?php if ( get_theme_mod('esports_blog_total_no_satisfied_counter_no_3') != '' || get_theme_mod('esports_blog_total_no_satisfied_counter_text_3') != '' ) { ?>
      <div class="customer-counter">
        <div class="customer-no"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_no_3', '')); ?></div>
        <div class="centers-text"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_text_3', '')); ?></div>
      </div>
    <?php } ?>
    <?php if ( get_theme_mod('esports_blog_total_no_satisfied_counter_no_4') != '' || get_theme_mod('esports_blog_total_no_satisfied_counter_text_4') != '' ) { ?>
      <div class="customer-counter">
        <div class="customer-no"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_no_4', '')); ?></div>
        <div class="centers-text"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_text_4', '')); ?></div>
      </div>
    <?php } ?>
    <?php if ( get_theme_mod('esports_blog_total_no_satisfied_counter_no_5') != '' || get_theme_mod('esports_blog_total_no_satisfied_counter_text_5') != '' ) { ?>
      <div class="customer-counter">
        <div class="customer-no"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_no_5', '')); ?></div>
        <div class="centers-text"><?php echo esc_html(get_theme_mod('esports_blog_total_no_satisfied_counter_text_5', '')); ?></div>
      </div>
    <?php } ?>
  </div>
<?php } ?>
