<?php 
$attorneys_enable = get_theme_mod( 'vw_book_store_pro_radio_testimonial_enable' );
if ( 'Disable' == $attorneys_enable ) {
  return;
}
$img_bg = get_theme_mod('vw_book_store_pro_our_testimonial_image_bg');
if( get_theme_mod('vw_book_store_pro_testimonial_bgcolor') ) { 
  $testi_backg = 'background-color:'.esc_attr(get_theme_mod('vw_book_store_pro_testimonial_bgcolor')).';';
}elseif( get_theme_mod('vw_book_store_pro_our_testimonial_bgimage') ){
  $testi_backg = 'background-image:url(\''.esc_url(get_theme_mod('vw_book_store_pro_our_testimonial_bgimage')).'\')';
}else{
  $testi_backg = '';   
}

if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
  $amp_class = 'col-lg-6 col-md-6 col-sm-12 col-12 mb-3';
  $amp_row = 'row';
}
else{
  $amp_class = '';
  $amp_row = '';
}

$args = array(
  'post_type' => 'testimonials',
  'post_status' => 'publish'
);
$new = new WP_Query($args); 

?>

<section id="testimonials" style="<?php echo esc_attr($testi_backg); ?>" class="wow slideInUp delay-3000 animated <?php echo esc_attr($img_bg); ?>" data-wow-duration="2s">
  <div class="container">
    <?php if(get_theme_mod('vw_book_store_pro_testimonial_title') != ''){?>
      <div class="section-title mb-4">
        <h3><?php echo esc_html(get_theme_mod('vw_book_store_pro_testimonial_title')); ?></h3>
      </div>
    <?php } ?>
    <div class="inner-test-bg">
      <?php
        if ( $new->have_posts() ) : ?>
        <div class="owl-carousel <?php echo esc_attr($amp_row); ?>">
          <?php          
            $loop_index = 0;
            $i=1;
            while ( $new->have_posts() ){
              $new->the_post();  ?>
              <div class="tesimonial_col <?php if($i == 1){ echo 'active';}?> <?php echo esc_attr($amp_class); ?>">
                <div class="media">
                  <?php if (has_post_thumbnail()){ ?>
                    <img class="d-flex me-md-4" src="<?php the_post_thumbnail_url(); ?>">
                  <?php } ?> 
                  <div class="media-body">
                    <h3 class="tesimonialtitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <small><?php echo esc_html(get_post_meta($post->ID,'vw_book_store_pro_posttype_testimonial_desigstory',true)); ?></small></h3>
                    <blockquote><p><i class="fas fa-quote-left"></i><?php $excerpt = get_the_excerpt(); echo esc_html(vw_book_store_pro_string_limit_words($excerpt,35)); ?><i class="fas fa-quote-right"></i></p></blockquote>
                  </div>
                </div>
              </div>
              <?php $i++;
            }
            wp_reset_query(); ?>
        </div>
      <?php 
        else :
          echo '<h5 class="text-center">' . esc_html__( 'Create the testimonials to make it appear here.', 'vw-book-store-pro' ) . '</h5>';
        endif;
      ?>
    </div>
  </div>
</section>
