<?php
$enable_sports_banner_section = sportsx_get_option('enable_sports_banner_section');
$banner_slider_post_category = sportsx_get_option('banner_slider_post_category');

$banner_lists_post_title = sportsx_get_option('banner_lists_post_title');
$banner_lists_post_category = sportsx_get_option('banner_lists_post_category');

$banner_featured_player_title = sportsx_get_option('banner_featured_player_title');
$banner_featured_player_category = sportsx_get_option('banner_featured_player_category');

$enable_sports_banner_author_meta = sportsx_get_option('enable_sports_banner_author_meta');
$select_sports_banner_author_meta = sportsx_get_option('select_sports_banner_author_meta');
$sports_banner_author_meta_title = sportsx_get_option('sports_banner_author_meta_title');

$enable_sports_banner_date_meta = sportsx_get_option('enable_sports_banner_date_meta');
$select_sports_banner_date = sportsx_get_option('select_sports_banner_date');
$select_sports_banner_date_meta_title = sportsx_get_option('select_sports_banner_date_meta_title');
$select_sports_banner_date_format = sportsx_get_option('select_sports_banner_date_format');

$enable_sports_banner_category_meta = sportsx_get_option('enable_sports_banner_category_meta');
$sports_banner_category_label = sportsx_get_option('sports_banner_category_label');
$select_sports_banner_category_color = sportsx_get_option('select_sports_banner_category_color');
$select_sports_banner_number_of_category = sportsx_get_option('select_sports_banner_number_of_category');
if (empty($enable_sports_banner_section)) {
    return;
}
?>


<section class="wpi-section theme-sports-banner">
  <div class="wrapper">
    <div class="row-group">
      <div class="column column-lg-10 border-lg-r border-md-r">
        <div class="sports-banner-top">
          <div class="sports-banner-slider swiper">
            <div class="swiper-wrapper">
                <?php
                // post slider section
                $post_slider_args = array(
                    'post_type' => 'post',
                    'posts_per_page' => 5,
                    'post_status' => 'publish',
                    'no_found_rows' => 1,
                    'ignore_sticky_posts' => 1,
                );
                // Check for category.
                if (!empty($banner_slider_post_category)) :
                    $post_slider_args['tax_query'] = array(
                        array(
                            'taxonomy' => 'category',
                            'field' => 'term_id',
                            'terms' => $banner_slider_post_category,
                        ),
                    );
                endif;
                $slider_posts = new WP_Query($post_slider_args);
                if ($slider_posts->have_posts()) :
                    while ($slider_posts->have_posts()) :
                        $slider_posts->the_post(); ?>
                        <div class="swiper-slide">
                          <article id="sports-banner-<?php the_ID(); ?>" class="banner-content-overlay">
                            <?php if (has_post_thumbnail()) : ?>
                                <div class="entry-image">
                                    <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"
                                       tabindex="-1">
                                        <?php
                                        the_post_thumbnail(
                                            'large',
                                            array(
                                                'alt' => the_title_attribute(
                                                    array(
                                                        'echo' => false,
                                                    )
                                                ),
                                            )
                                        );
                                        ?>
                                    </a>
                                </div>
                            <?php endif; ?>

                            <div class="entry-details">
                              <div>
                                <?php
                                if ($enable_sports_banner_category_meta) {
                                    sportsx_post_category($select_sports_banner_category_color, $sports_banner_category_label, $select_sports_banner_number_of_category);
                                }
                                ?>
                                <h3 class="entry-title entry-title-large">
                                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                </h3>

                                <div class="entry-content-excerpt hide-on-mobile">
                                    <?php echo wpautop(wp_kses_post(sportsx_get_archive_excerpt())); ?>
                                </div>
                              </div>

                                <div class="entry-meta-wrapper">

                                    <?php
                                    if ($enable_sports_banner_date_meta) {
                                        sportsx_posted_on($select_sports_banner_date_format, $select_sports_banner_date_meta_title, $select_sports_banner_date);
                                    }
                                    ?>

                                    <?php
                                    if ($enable_sports_banner_author_meta) {
                                        sportsx_posted_by($select_sports_banner_author_meta, $sports_banner_author_meta_title);
                                    }
                                    ?>

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

            <div class="swiper-pagination"></div>
            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev"></div>
          </div>
        </div>

        <div class="sports-banner-middle">
          <?php if ($banner_lists_post_title) { ?>
              <h2 class="banner-middle-title"><?php echo esc_html($banner_lists_post_title); ?> </h2>
          <?php } ?>

          <div class="banner-middle-details">

            <?php
            // post grid middle section
            $post_list_args = array(
                'post_type' => 'post',
                'posts_per_page' => 4,
                'post_status' => 'publish',
                'no_found_rows' => 1,
                'ignore_sticky_posts' => 1,
            );
            // Check for category.
            if (!empty($banner_lists_post_category)) :
                $post_list_args['tax_query'] = array(
                    array(
                        'taxonomy' => 'category',
                        'field' => 'term_id',
                        'terms' => $banner_lists_post_category,
                    ),
                );
            endif;
            $count = 1;
            $slider_list_posts = new WP_Query($post_list_args);
            if ($slider_list_posts->have_posts()) :
                while ($slider_list_posts->have_posts()) :
                    $slider_list_posts->the_post(); ?>
                    <article id="sports-banner-<?php the_ID(); ?>"
                      class="wpi-post post-122 post type-post status-publish format-standard has-post-thumbnail hentry category-editorial category-fashion tag-12 tag-outfit tag-summer tag-wear">
                      <span class="article-index"> <?php echo absint($count++); ?> </span>
                      <div class="entry-details">
                          <?php
                          if ($enable_sports_banner_category_meta) {
                              sportsx_post_category($select_sports_banner_category_color, $sports_banner_category_label, $select_sports_banner_number_of_category);
                          }
                          ?>
                          <h3 class="entry-title entry-title-small">
                              <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                          </h3>
                          <div class="entry-meta-wrapper">

                              <?php
                              if ($enable_sports_banner_date_meta) {
                                  sportsx_posted_on($select_sports_banner_date_format, $select_sports_banner_date_meta_title, $select_sports_banner_date);
                              }
                              ?>

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

          </div>
        </div>

      </div>

      <div class="column column-lg-2">
        <div class="sports-banner-right">
          <?php if ($banner_featured_player_title) { ?>
            <header class="wpi-section-header">
              <h2 class="section-header-title"><?php echo esc_html($banner_featured_player_title); ?> </h2>
            </header>
          <?php } ?>
          <div class="banner-right-slider swiper">
            <div class="swiper-wrapper">

              <?php
              // post grid middle section
              $post_player_args = array(
                  'post_type' => 'post',
                  'posts_per_page' => 3,
                  'post_status' => 'publish',
                  'no_found_rows' => 1,
                  'ignore_sticky_posts' => 1,
              );
              // Check for category.
              if (!empty($banner_featured_player_category)) :
                  $post_player_args['tax_query'] = array(
                      array(
                          'taxonomy' => 'category',
                          'field' => 'term_id',
                          'terms' => $banner_featured_player_category,
                      ),
                  );
              endif;
              $count = 1;
              $slider_player_posts = new WP_Query($post_player_args);
              if ($slider_player_posts->have_posts()) :
                  while ($slider_player_posts->have_posts()) :
                      $slider_player_posts->the_post(); ?>
                      <div class="swiper-slide">
                        <article id="sports-banner-<?php the_ID(); ?>">
                          <h2 class="entry-title entry-title-medium"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                          
                          <?php if (has_post_thumbnail()) : ?>
                              <div class="entry-image image-hover-effect hover-effect-shine">
                                  <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"
                                     tabindex="-1">
                                      <?php
                                      the_post_thumbnail(
                                          'medium',
                                          array(
                                              'alt' => the_title_attribute(
                                                  array(
                                                      'echo' => false,
                                                  )
                                              ),
                                          )
                                      );
                                      ?>
                                  </a>
                              </div>
                          <?php endif; ?>

                          <div class="entry-content-excerpt">
                            <?php sportsx_the_theme_svg('quote'); ?>
                            <?php echo wpautop(wp_kses_post(sportsx_get_archive_excerpt())); ?>
                          </div>

                        </article>
                      </div>

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

            </div>

            <div class="swiper-pagination"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>