<?php
/**
 * Testimonial Display Class
 * Handles testimonial display functionality in checkout
 * 
 * @package Checkoutify_Lite
 * @since 1.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Testimonial Display Class
 * Manages testimonial display in checkout templates
 */
class CKFYLT25_Testimonial_Display {

    /**
     * Constructor - Initialize testimonial display hooks
     */
    public function __construct() {
        add_action( 'ckfylt25_after_order_summary', array( $this, 'ckfylt25_render_testimonials' ) );
    }

    /**
     * Render testimonials in checkout
     */
    public function ckfylt25_render_testimonials() {
        if ( ! get_option( 'ckfylt25_testimonials_enabled' ) ) {
            return;
        }
        $testimonials = get_option( 'ckfylt25_testimonials_data' );
        if ( empty( $testimonials ) || ! is_array( $testimonials ) ) {
            return;
        }
        echo '<div class="ckfylt25-testimonials-container">';
        foreach ( $testimonials as $testimonial ) {
            ?>
            <div class="ckfylt25-testimonial">
                <?php if ( ! empty( $testimonial['image_url'] ) ) : ?>
                    <div class="ckfylt25-testimonial__image">
                        <img src="<?php echo esc_url( $testimonial['image_url'] ); ?>" alt="<?php echo esc_attr( $testimonial['author'] ); ?>">
                    </div>
                <?php endif; ?>
                <div class="ckfylt25-testimonial__content">
                    <div class="ckfylt25-testimonial__text">
                        <p>"<?php echo esc_html( $testimonial['content'] ); ?>"</p>
                    </div>
                    <div class="ckfylt25-testimonial__author">
                        &mdash; <?php echo esc_html( $testimonial['author'] ); ?>
                    </div>
                </div>
            </div>
            <?php
        }
        echo '</div>';
    }
}
