<?php
/**
 * Testimonial Section
 *
 * @package Excel_Business
 */

$ed_section = get_theme_mod( 'ed_testimonial', true );
$title      = get_theme_mod( 'testimonial_title', __( 'What our clients says', 'excel-business' ) );
$sub_title  = get_theme_mod( 'testimonial_subtitle', __( 'Let your visitor know the real testimonial from here. You can customize this section from Appearance > Customize > Home Page Settings > Testimonial Section.', 'excel-business' ) );

$image = get_theme_mod( 'testimonial_bg', get_template_directory_uri() . '/images/img8.jpg' );
if( $image ){
    $bg = ' style="background: url(' . esc_url( $image ) . ') no-repeat;"';
}else{
    $bg = '';
}

$args = array(
    'post_type'      => 'ea_testimonial',
    'post_status'    => 'publish',
    'posts_per_page' => -1
);

$qry = new WP_Query( $args );

if( $ed_section && ( $title || $sub_title || $qry->have_posts() ) ){ ?>
<section class="testimonial"<?php echo $bg; ?>>
	<div class="container">
		
        <?php
            excel_business_get_section_header( $title, $sub_title );
            
            if( excel_business_is_ea_active() && $qry->have_posts() ){
            ?>
    		<div class="testimonial-holder">
    			<div class="owl-carousel owl-theme" id="testimonial-slider">
    				<?php 
                    while( $qry->have_posts() ){ 
                        $qry->the_post();?>
                        <div class="item">        					
                            <div class="img-holder">
  						    <?php 
                                if( has_post_thumbnail() ){
                                    the_post_thumbnail( 'thumbnail' );        						  
        						}
                            ?>                                
        					</div>
        					<div class="text-holder">
        						<?php 
                                    the_excerpt();
                                    printf( esc_html__( '%1$s- %2$s%3$s', 'excel-business' ), '<strong class="cite">', get_the_title(), '</strong>' );
                                ?>
        					</div>
        				</div>
        				<?php 
                    }
                    wp_reset_postdata(); 
                    ?>
    			</div>
    		</div>
            <?php
            }
        ?>
        
	</div>
</section>
<?php
}