<?php
/**
 * Banner Section
 * 
 * @package ott_tv_shows
 */
$ott_tv_shows_slider = get_theme_mod( 'ott_tv_shows_slider_setting',false );
$ott_tv_shows_card = get_theme_mod( 'ott_tv_shows_cards_setting',false );
$ott_tv_shows_args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' =>  get_theme_mod('ott_tv_shows_blog_slide_category'),
  'posts_per_page' => 3,
); ?>

<?php if ( $ott_tv_shows_slider ){?>
  <div class="banner">
    <div class="owl-carousel">
      <?php $ott_tv_shows_arr_posts = new WP_Query( $ott_tv_shows_args );
      if ( $ott_tv_shows_arr_posts->have_posts() ) :
        while ( $ott_tv_shows_arr_posts->have_posts() ) :
          $ott_tv_shows_arr_posts->the_post();
          ?>
          <div class="banner_inner_box">
            <?php
              if ( has_post_thumbnail() ) :
                the_post_thumbnail();
              else:
                ?>
                <div class="banner_inner_box">
                  <img src="<?php echo get_stylesheet_directory_uri() . '/images/slide.png'; ?>">
                </div>
                <?php
              endif;
            ?>
            <div class="banner_box">
              <?php if ( get_theme_mod('ott_tv_shows_slider_text_extra') ) : ?>
                <h5><?php echo esc_html(get_theme_mod('ott_tv_shows_slider_text_extra'));?></h5>
              <?php endif; ?>
              <h3 class="my-3"><?php the_title(); ?></a></h3>
              <p class="mb-0"><?php echo wp_trim_words(get_the_content(), 20); ?></p>
              <div class="slide-btns">
                <p class="btn-green mt-4">
                <a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php esc_html_e('Read More','ott-tv-shows'); ?></a>
              </p>
              </div>
            </div>
          </div>
        <?php
      endwhile;
      wp_reset_postdata();
      endif; ?>
    </div>
              <?php if ( $ott_tv_shows_card ){ ?>
              <div class="card-main-box">
                  <div class="row">
                      <?php 
                          for ($ott_tv_shows_i = 1; $ott_tv_shows_i <= 4; $ott_tv_shows_i++) { 
                          $ott_tv_shows_card_title = get_theme_mod('ott_tv_shows_card_title' . $ott_tv_shows_i, '');
                          $ott_tv_shows_card_text = get_theme_mod('ott_tv_shows_card_text' . $ott_tv_shows_i, '');
                          $ott_tv_shows_icon = get_theme_mod('ott_tv_shows_card_icon' . $ott_tv_shows_i, '');
                          ?>
                          <div class="col-xl-3 col-lg-6 col-md-6 col-sm-6 col-12 align-self-center p-0 my-2">
                            <?php if (!empty($ott_tv_shows_icon) || !empty($ott_tv_shows_card_title) || !empty($ott_tv_shows_card_text)) { ?>
                              <div class="card-box p-2">
                                  <div class="row">
                                      <div class="col-lg-3 col-3 align-self-center">
                                          <div class="icon">
                                              <?php if (!empty($ott_tv_shows_icon)) { ?>
                                                  <i class="<?php echo esc_attr($ott_tv_shows_icon); ?>"></i>
                                              <?php } ?>
                                          </div>
                                      </div>
                                      <div class="col-lg-9 col-9 align-self-center">
                                        <?php if (!empty($ott_tv_shows_card_title)) { ?>
                                          <p class="card-heading mb-0"><?php echo esc_html($ott_tv_shows_card_title); ?></p>
                                        <?php } ?>
                                        <?php if (!empty($ott_tv_shows_card_text)) { ?>
                                          <p class="card-text mb-0"><?php echo esc_html($ott_tv_shows_card_text); ?></p>
                                        <?php } ?>
                                      </div>
                                  </div>
                              </div>
                            <?php } ?>
                          </div>
                      <?php } ?>
                  </div>
              </div>
        <?php } ?>
  </div>
<?php } ?>