<?php
/**
 * Banner Section
 * 
 * @package safety_wear
 */
$safety_wear_slider     = get_theme_mod( 'safety_wear_slider_setting',false );
$safety_wear_slider_button_1     = get_theme_mod( 'safety_wear_slider_button_1_setting',true );
$safety_wear_slider_button_2     = get_theme_mod( 'safety_wear_slider_button_2_setting',true );

$safety_wear_args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' =>  get_theme_mod('safety_wear_blog_slide_category'),
  'posts_per_page' => 3,
); ?>
<?php if ( $safety_wear_slider ){?>
  <div class="banner">
    <div class="owl-carousel">
      <?php $safety_wear_arr_posts = new WP_Query( $safety_wear_args );
      if ( $safety_wear_arr_posts->have_posts() ) :
        while ( $safety_wear_arr_posts->have_posts() ) :
          $safety_wear_arr_posts->the_post();
          ?>
          <div class="banner_inner_box">
            <?php
              if ( has_post_thumbnail() ) :
                the_post_thumbnail();
              else:
                ?>
                <div class="image-container">
                  <img src="<?php echo get_stylesheet_directory_uri() . '/images/banner.jpg'; ?>">
                </div>
                <?php
              endif;
            ?>
              <div class="banner_box wow zoomIn" data-wow-duration="2s">
                  <?php if ( get_theme_mod('safety_wear_slider_text_extra') ) : ?>
                    <h5><?php echo esc_html(get_theme_mod('safety_wear_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(), 30 ); ?></p>
                  <div class="slider-buttons">
                     <?php if ( $safety_wear_slider_button_1 ){?>
                      <p class="btn-green mt-4">
                        <i class="far fa-hand-point-right"></i><a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php esc_html_e('Discover Now','safety-wear'); ?></a>
                      </p>
                    <?php } ?>
                    <?php if ( get_theme_mod('safety_wear_slider_second_button_url') ) : ?>
                      <p class="btn-green-2 mt-4">
                        <i class="fas fa-bolt"></i><a target="_blank" href="<?php echo esc_url(get_theme_mod('safety_wear_slider_second_button_url'));?>"><?php esc_html_e('Go Safety','safety-wear'); ?></a>
                      </p>
                    <?php endif; ?>
                </div>
              </div>
          </div>
        <?php
      endwhile;
      wp_reset_postdata();
      endif; ?>
    </div>
  </div>
<?php } ?>