|
<?php |
|
|
|
/** |
|
* Display testimonials |
|
*/ |
|
function wds_meltwater_testimonials( $type = '' ) { |
|
|
|
// Grab the type set for this layout |
|
$type = esc_html( get_post_meta( get_the_ID(), '_wds_meltwater_type_select', true ) ); |
|
|
|
echo wds_meltwater_get_testimonials( $type ); |
|
} |
|
|
|
/** |
|
* Grab the testimonials |
|
*/ |
|
function wds_meltwater_get_testimonials( $type ) { |
|
|
|
// Grab the type set for this layout |
|
$type = $type ? $type : esc_html( get_post_meta( get_the_ID(), '_wds_meltwater_type_select', true ) ); |
|
|
|
// Grab the posts per page |
|
$posts_per_page = get_post_meta( get_the_ID(), '_wds_meltwater_posts_per_page', true ); |
|
|
|
// Query for our posts |
|
if ( isset( $_GET['delete-trans'] ) || ! ( $testimonials = get_transient( 'wds_meltwater_featured_testimonials' ) ) ) { |
|
|
|
$post_args = array( |
|
'post_type' => 'testimonial', |
|
'posts_per_page' => intval( $posts_per_page ), |
|
'tax_query' => array( |
|
array( |
|
'taxonomy' => 'type', |
|
'field' => 'slug', |
|
'terms' => $type, |
|
), |
|
), |
|
// 'meta_key' => '_wds_meltwater_featured', |
|
// 'meta_value' => 'on' |
|
); |
|
|
|
$testimonials = new WP_Query( $post_args ); |
|
|
|
set_transient( 'wds_meltwater_featured_testimonials', $testimonials, 24 * HOUR_IN_SECONDS ); |
|
} |
|
|
|
|
|
if ( ! $testimonials->have_posts() ) { |
|
return; |
|
} |
|
|
|
// Enqueue our animate.js file |
|
wp_enqueue_script( 'animate' ); |
|
|
|
$output = '<h1>' . sprintf( __( "What our %s say", "meltwater" ), $type ) . '</h1>'; |
|
$output .= '<div id="testimonials-carousel" class="testimonials-wrap">'; |
|
|
|
while ( $testimonials->have_posts() ) { |
|
$testimonials->the_post(); |
|
|
|
$thumb = get_the_post_thumbnail( get_the_ID(), 'testimonial' ); |
|
|
|
$output .= '<div class="testimonial revealOnScroll" data-animation="fadeIn" data-timeout="500">'; |
|
$output .= $thumb ? '<div class="customer-avatar">' . $thumb . '</div>' : ''; |
|
$output .= '<div class="quote">'; |
|
$output .= '<p>' . wp_trim_words( get_the_content(), 15, '' ) . '</p>' |
|
. '<div class="customer">' . get_the_title() . '</div></div>'; |
|
$output .= '</div>'; |
|
} |
|
|
|
wp_reset_postdata(); |
|
|
|
$output .= '</div>'; |
|
|
|
if ($type == 'staff') { |
|
$output .= '<p class="footer-link"><a href="#" class="button">' . __( 'Find openings', 'meltwater' ) . wds_meltwater_after_button() . '</a></p>'; |
|
} else { |
|
$output .= '<p class="footer-link"><a href="#" class="button">' . __( 'Meltwater case studies', 'meltwater' ) . wds_meltwater_after_button() . '</a></p>'; |
|
} |
|
|
|
return $output; |
|
|
|
} |