<?php
/**
 * Template part for displaying slider section
 *
 * @package Videographer Studio
 * @subpackage videographer_studio
 */

?>
<?php $videographer_studio_static_image = get_stylesheet_directory_uri() . '/assets/images/slider-img.png'; ?>
<?php if( get_theme_mod( 'videographer_studio_slider_arrows', true) != '') { ?>

<section id="slider">
  <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
    <?php $videographer_studio_slide_pages = array();
      for ( $videographer_studio_count = 1; $videographer_studio_count <= 4; $videographer_studio_count++ ) {
        $videographer_studio_mod = intval( get_theme_mod( 'videographer_studio_slider_page' . $videographer_studio_count ));
        if ( 'page-none-selected' != $videographer_studio_mod ) {
          $videographer_studio_slide_pages[] = $videographer_studio_mod;
        }
      }
      if( !empty($videographer_studio_slide_pages) ) :
        $videographer_studio_args = array(
          'post_type' => 'page',
          'post__in' => $videographer_studio_slide_pages,
          'orderby' => 'post__in'
        );
        $videographer_studio_query = new WP_Query( $videographer_studio_args );
        if ( $videographer_studio_query->have_posts() ) :
          $i = 1;
    ?>
    <div class="carousel-inner" role="listbox">
      <?php  while ( $videographer_studio_query->have_posts() ) : $videographer_studio_query->the_post(); ?>
        <div <?php if($i == 1){echo 'class="carousel-item active"';} else{ echo 'class="carousel-item"';}?>>
          <?php if(has_post_thumbnail()){ ?>
             <img src="<?php the_post_thumbnail_url('full'); ?>"/>
              <?php }else {echo ('<img src="'.$videographer_studio_static_image.'">'); } ?>
          <div class="carousel-caption">
            <div class="inner_carousel">
              <p><?php echo esc_html( get_theme_mod( 'videographer_studio_slider_title','' ) ); ?></p>
              <?php if (get_theme_mod('videographer_studio_show_slider_title', true)) : ?>
                <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
              <?php endif; ?>
                <div class="more-btn">
                  <a class="btn-1" href="<?php the_permalink(); ?>"><?php esc_html_e('Info More','videographer-studio'); ?></a>
                  <?php if( get_theme_mod( 'videographer_studio_slider_button_1_link' ) != '' || get_theme_mod( 'videographer_studio_slider_button_1' ) != '') { ?>
                    <span><a href="<?php echo esc_url( get_theme_mod( 'videographer_studio_slider_button_1_link','' ) ); ?>"><?php echo esc_html( get_theme_mod( 'videographer_studio_slider_button_1','' ) ); ?></a></span>                  
                  <?php } ?>
                </div>
            </div>
          </div>
        </div>
      <?php $i++; endwhile;
      wp_reset_postdata();?>
    </div>
    <?php else : ?>
        <div class="no-postfound"></div>
      <?php endif;
    endif;?>
    <div class="phone-box">
      <div class="row m-0">
        <div class="col-lg-6 col-md-6 align-self-center">
            <?php if( get_theme_mod( 'videographer_studio_award_text' ) != '' || get_theme_mod( 'videographer_studio_award' ) != '') { ?>
            <div class="first-box">
              <div class="row">
                <div class="col-lg-3 col-md-3 col-sm-3 align-self-center">
                <i class="fas fa-newspaper"></i>
                </div>
                <div class="col-lg-9 col-md-9 col-sm-9 align-self-center">
                  <h2><?php echo esc_html( get_theme_mod('videographer_studio_award_text' ) ); ?></h2>
                  <p class="mb-0"><?php echo esc_html( get_theme_mod('videographer_studio_award' ) ); ?></p>
                </div>
              </div>
            </div>
          <?php } ?>
        </div>
        <div class="col-lg-6 col-md-6 align-self-center">
          <?php get_template_part( 'template-parts/header/social', 'icon' ); ?>
        </div>
      </div>
    </div>
    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-bs-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"><i class="fas fa-angle-left"></i></span>
      <span class="screen-reader-text"><?php esc_html_e('Previous','videographer-studio'); ?></span>
    </a>
    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-bs-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"><i class="fas fa-angle-right"></i></span>
      <span class="screen-reader-text"><?php esc_html_e('Next','videographer-studio'); ?></span>
    </a> 
  </div>
  <div class="clearfix"></div>
</section>

<?php } ?>
