<?php 
$author_enable = get_theme_mod( 'vw_book_store_pro_radio_author_enable' );
if ( 'Disable' == $author_enable ) {
  return;
}
$img_bg = get_theme_mod('vw_book_store_pro_our_author_image_bg');
if( get_theme_mod('vw_book_store_pro_author_bgcolor') ) { 
  $about_backg = 'background-color:'.esc_attr(get_theme_mod('vw_book_store_pro_author_bgcolor')).';';
}elseif( get_theme_mod('vw_book_store_pro_our_author_bgimage') ){
  $about_backg = 'background-image:url(\''.esc_url(get_theme_mod('vw_book_store_pro_our_author_bgimage')).'\')';
}else{
  $about_backg = '';   
}

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

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

?>
  <section id="author" style="<?php echo esc_html($about_backg); ?>" class="wow zoomIn 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_author_title',true) != ''){?>
      <div class="section-title">
        <h3><?php echo esc_html(get_theme_mod('vw_book_store_pro_author_title')); ?></h3>
      </div>
    <?php } ?>
    <?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="<?php if($i == 1){ echo 'active';}?> <?php echo esc_attr($amp_class); ?>"> 
            <div class="author_wrap">
              <?php if (has_post_thumbnail()){ ?>
                <div class="authorbox">
                  <?php the_post_thumbnail(); ?>                  
                  <div class="authorbox-content">
                    <div class="socialbox">                           
                      <?php if(get_post_meta($post->ID,'meta-facebookurl',true) || get_post_meta($post->ID,'meta-twitterurl',true) || get_post_meta($post->ID,'meta-googleplusurl',true) || get_post_meta($post->ID,'meta-linkdenurl',true)){?>
                          <?php if(get_post_meta($post->ID,'meta-facebookurl',true)){?>
                            <a class="" href="<?php echo esc_html(get_post_meta($post->ID,'meta-facebookurl',true)); ?>" target="_blank"><i class="fab fa-facebook-f"></i></a>
                          <?php } if(get_post_meta($post->ID,'meta-twitterurl',true)){?>
                            <a class="" href="<?php echo esc_html(get_post_meta($post->ID,'meta-twitterurl',true)); ?>" target="_blank"><i class="fab fa-twitter"></i></a>                              
                          <?php } if(get_post_meta($post->ID,'meta-linkdenurl',true)){?>
                            <a class="" href="<?php echo esc_html(get_post_meta($post->ID,'meta-linkdenurl',true)); ?>" target="_blank"><i class="fab fa-linkedin-in"></i></a>
                            <?php } if(get_post_meta($post->ID,'meta-instagramurl',true)){?>
                            <a class="" href="<?php echo esc_html(get_post_meta($post->ID,'meta-instagramurl',true)); ?>" target="_blank"><i class="fab fa-instagram"></i></a>
                          <?php } ?>
                      <?php }?>
                    </div>
                  </div>                  
                </div>
                <div class="image-title">
                  <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                  <?php if(get_post_meta($post->ID,'meta-designation',true)){?>
                  <span><?php echo esc_html(get_post_meta($post->ID,'meta-designation',true)); ?></span>
                  <?php }?>
                </div>
              <?php } ?>                    
            </div>
          </div>
        <?php $i++; }
        wp_reset_query(); ?>
      </div>
      <?php
        else :
          echo '<h5 class="text-center">' . esc_html__( 'Create the author to make it appear here.', 'vw-book-store-pro' ) . '</h5>'; 
        endif;
      ?>
    </div>
    <div class="clearfix"></div>
  </section>
