Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function evisioncorporatepro_front_testimonial() {
global $evisioncorporatepro_customizer_all_values;
$evisioncorporatepro_testimonials = coder_get_repeated_all_value('evisioncorporatepro-testimonial');
if( isset( $evisioncorporatepro_customizer_all_values['evisioncorporatepro-testimonial-enable']) && 1 == $evisioncorporatepro_customizer_all_values['evisioncorporatepro-testimonial-enable'] ) {
$evisioncorporatepro_testimonial_pages_ids = array();
if( null != $evisioncorporatepro_testimonials ) {
foreach($evisioncorporatepro_testimonials as $evisioncorporatepro_testimonial) {
if( 0 != $evisioncorporatepro_testimonial['evisioncorporatepro-testimonial-pages'] ){
$evisioncorporatepro_testimonial_pages_ids[] = $evisioncorporatepro_testimonial['evisioncorporatepro-testimonial-pages'];
}
}
}
?>
<!-- *****************************************
testimonial section start
****************************************** -->
<section id="evisioncorporatepro-testimonial" class="wrapper block-testimonial block-section block-bg-image">
<div class="block-overlay"> &nbsp; </div>
<div class="block-overlay-content">
<div class="container">
<div class="block-title">
<?php
if(isset($evisioncorporatepro_customizer_all_values['evisioncorporatepro-testimonial-main-title']) && !empty($evisioncorporatepro_customizer_all_values['evisioncorporatepro-testimonial-main-title']) ){
echo '<h2>'.wp_kses_post( $evisioncorporatepro_customizer_all_values['evisioncorporatepro-testimonial-main-title'] ).'</h2>';
echo '<div class="block-title-divider"><span><i class="fa fa-circle"></i></span></div>';
}
?>
</div>
<?php
if( !empty ( $evisioncorporatepro_testimonial_pages_ids ) ) {
?>
<div class="testimonial-container">
<div id='evisioncorporatepro-testimonial-slide' class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
$evisioncorporatepro_testimonial_query = new WP_Query(
array(
'post_type' => 'page',
'post__in' => $evisioncorporatepro_testimonial_pages_ids,
'posts_per_page' => 6,
'orderby' => 'post__in'
)
);
// the query
if ( $evisioncorporatepro_testimonial_query->have_posts() ) :
/*loop*/
$testimonial_index = 0;
while ( $evisioncorporatepro_testimonial_query->have_posts() ) :
$evisioncorporatepro_testimonial_query->the_post();
if( 0 == $testimonial_index){
$evisioncorporatepro_active= 'active';
}
else{
$evisioncorporatepro_active= '';
}
?>
<div class="item <?php echo esc_attr( $evisioncorporatepro_active );?>">
<div class="testimonial-content evisioncorporatepro-carousel-fixed-content">
<?php echo evisioncorporatepro_words_count( 50, get_the_content() )?>
</div>
<div class="testimonial-sayer">
<a href="<?php the_permalink(); ?>"><?php the_title();?></a>
</div>
</div>
<?php
$testimonial_index++;
?>
<?php endwhile; ?>
<!-- end of the loop -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<!--Probably this message never display-->
<p><?php _e( 'Please select pages for testimonial, also make sure to have featured image for all pages', 'evisioncorporatepro' )?></p>
<?php endif;?>
</div>
<!-- Indicators -->
<ol class="carousel-indicators">
<?php
// the query
if ( $evisioncorporatepro_testimonial_query->have_posts() ) :
/*loop*/
$testimonial_index = 0;
while ( $evisioncorporatepro_testimonial_query->have_posts() ) :
$evisioncorporatepro_testimonial_query->the_post();
if( 0 == $testimonial_index){
$evisioncorporatepro_active= 'active';
}
else{
$evisioncorporatepro_active= '';
}
?>
<li class="evisioncorporatepro-indicators-image <?php echo esc_attr( $evisioncorporatepro_active );?>" data-target="#evisioncorporatepro-testimonial-slide" data-slide-to="<?php echo esc_attr( $testimonial_index );?>">
<?php
if ( '' != get_the_post_thumbnail() ) {
the_post_thumbnail();
} else {
echo "<img src='".esc_url(get_template_directory_uri().'/assets/img/avatar.png')."' alt='".__('evisioncorporatepro-no-image','evisioncorporatepro')."'>";
}
?>
</li>
<?php
$testimonial_index++;
?>
<?php endwhile; ?>
<!-- end of the loop -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Please select pages for testimonial, also make sure to have all pages have featured image', 'evisioncorporatepro' )?></p>
<?php endif;?>
</ol>
</div>
</div>
<?php
}
?>
</div>
</div>
</section>
<!-- *****************************************
testimonial section ends
****************************************** -->
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.