content.php
91 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template Name: Default |
| 4 | * Description: Inherits your theme's styles for a seamless look. |
| 5 | */ |
| 6 | |
| 7 | do_action( 'wpmtst_before_view' ); |
| 8 | |
| 9 | ?> |
| 10 | |
| 11 | <div class="strong-view <?php wpmtst_container_class(); ?>"<?php wpmtst_container_data(); ?>> |
| 12 | <?php do_action( 'wpmtst_view_header' ); ?> |
| 13 | |
| 14 | <div class="strong-content <?php wpmtst_content_class(); ?>"> |
| 15 | <?php do_action( 'wpmtst_before_content', $atts ); ?> |
| 16 | <?php |
| 17 | // Drop the unprefixed "testimonial" class — this template only uses wpmtst-* classes. |
| 18 | $wpmtst_strip_unprefixed_post_class = function ( $classes ) { |
| 19 | return implode( ' ', array_diff( explode( ' ', $classes ), array( 'testimonial' ) ) ); |
| 20 | }; |
| 21 | add_filter( 'wpmtst_post_class', $wpmtst_strip_unprefixed_post_class ); |
| 22 | |
| 23 | while ( $query->have_posts() ) : |
| 24 | $query->the_post(); |
| 25 | ?> |
| 26 | <?php |
| 27 | $wpmtst_avatar_html = wpmtst_get_thumbnail(); |
| 28 | /* |
| 29 | * Read the configured height directly rather than parsing it back out of the |
| 30 | * rendered <img> tag — WordPress doesn't always emit width/height attributes |
| 31 | * that match the requested size (e.g. non-croppable images), which threw the |
| 32 | * overlap math off for some photos. |
| 33 | */ |
| 34 | $wpmtst_avatar_height = 0; |
| 35 | if ( $wpmtst_avatar_html ) { |
| 36 | $wpmtst_avatar_height = 'custom' === WPMST()->atts( 'thumbnail_size' ) |
| 37 | ? (int) WPMST()->atts( 'thumbnail_height' ) |
| 38 | : 100; |
| 39 | } |
| 40 | ?> |
| 41 | <div class="<?php wpmtst_post_class( $atts ); ?> wp-block-post wp-block-group" style="--wpmtst-avatar-size: <?php echo esc_attr( $wpmtst_avatar_height ); ?>px;"> |
| 42 | <div class="wpmtst-testimonial-inner"> |
| 43 | <?php do_action( 'wpmtst_before_testimonial' ); ?> |
| 44 | |
| 45 | <?php if ( $wpmtst_avatar_html ) : ?> |
| 46 | <figure class="wp-block-image wpmtst-testimonial-avatar"><?php echo $wpmtst_avatar_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already filtered/escaped by wpmtst_get_thumbnail(). ?></figure> |
| 47 | <?php endif; ?> |
| 48 | |
| 49 | <?php wpmtst_the_title( 'h2', 'wp-block-heading wpmtst-testimonial-heading' ); ?> |
| 50 | |
| 51 | <?php |
| 52 | if ( isset( $atts['client_section'] ) && is_array( $atts['client_section'] ) ) { |
| 53 | foreach ( $atts['client_section'] as $field ) { |
| 54 | if ( 'author' === ( $field['type'] ?? '' ) ) { |
| 55 | $wpmtst_author_value = wpmtst_get_field( $field['field'] ); |
| 56 | if ( $wpmtst_author_value ) { |
| 57 | printf( |
| 58 | '<h2 class="wp-block-heading wpmtst-testimonial-field %s">%s</h2>', |
| 59 | esc_attr( $field['class'] ?? '' ), |
| 60 | wp_kses_post( $wpmtst_author_value ) |
| 61 | ); |
| 62 | } |
| 63 | continue; |
| 64 | } |
| 65 | echo wpmtst_the_custom_field_as_paragraph( $field ); |
| 66 | } |
| 67 | } |
| 68 | ?> |
| 69 | |
| 70 | <div class="wpmtst-testimonial-content"> |
| 71 | <?php wpmtst_the_content(); ?> |
| 72 | <?php do_action( 'wpmtst_after_testimonial_content' ); ?> |
| 73 | </div> |
| 74 | |
| 75 | <?php do_action( 'wpmtst_after_testimonial', $atts ); ?> |
| 76 | </div> |
| 77 | |
| 78 | </div> |
| 79 | <?php endwhile; ?> |
| 80 | |
| 81 | <?php |
| 82 | remove_filter( 'wpmtst_post_class', $wpmtst_strip_unprefixed_post_class ); |
| 83 | do_action( 'wpmtst_after_content', $atts ); |
| 84 | ?> |
| 85 | </div> |
| 86 | |
| 87 | <?php do_action( 'wpmtst_view_footer' ); ?> |
| 88 | </div> |
| 89 | |
| 90 | <?php do_action( 'wpmtst_after_view' ); ?> |
| 91 |