<?php
/**
 * Testimonial section template for Home Page
 *
 * @package Edutechstar
 */

// Check if section is enabled in Customizer (default is active)
if ( get_theme_mod( 'edutechstar_Testimonial_Section_Enable', '1' ) ) :

    $title    = get_theme_mod( 'edutechstar_Testimonial_Section_Title', __( 'What Our Students Say', 'edutechstar' ) );
    $subtitle = get_theme_mod( 'edutechstar_Testimonial_Section_Subtitle', __( 'Read reviews and testimonials from our successful students and alumni.', 'edutechstar' ) );

    $defaults = array(
        1 => array(
            'name'        => 'John Doe',
            'designation' => 'Software Engineer, Google',
            'quote'       => 'Edutechstar is a fantastic theme. It helped me build my website in no time and the features are extremely robust.',
        ),
        2 => array(
            'name'        => 'Steve Smith',
            'designation' => 'Web Designer, Weblizar',
            'quote'       => 'Highly recommend this theme for educational institutions. It has very clean code and responsive layouts.',
        ),
        3 => array(
            'name'        => 'Sarah Connor',
            'designation' => 'Student, MIT University',
            'quote'       => 'I learned so much using this platform. The website\'s design is top-notch and user experience is flawless.',
        ),
    );
?>
<!-- Start Testimonials Section -->
<section id="mu-testimonial">
  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <div class="mu-testimonial-area">
          
          <!-- start title -->
          <div class="mu-title">
            <h2><?php echo esc_html( $title ); ?></h2>
            <p><?php echo esc_html( $subtitle ); ?></p>
          </div>
          <!-- end title -->
          
          <!-- start testimonial content -->
          <div class="mu-testimonial-content">
            <?php 
            for ( $i = 1; $i <= 3; $i++ ) {
                $name        = get_theme_mod( "edutechstar_testimonial_{$i}_name", $defaults[$i]['name'] );
                $designation = get_theme_mod( "edutechstar_testimonial_{$i}_designation", $defaults[$i]['designation'] );
                $quote       = get_theme_mod( "edutechstar_testimonial_{$i}_quote", $defaults[$i]['quote'] );
                $image       = get_theme_mod( "edutechstar_testimonial_{$i}_image", '' );

                // Only render if there is a name or a quote
                if ( ! empty( $name ) || ! empty( $quote ) ) :
            ?>
              <!-- start single testimonial item -->
              <div class="mu-testimonial-item">
                <div class="mu-testimonial-quote">
                  <blockquote>
                    <?php echo wp_kses_post( $quote ); ?>
                  </blockquote>
                </div>
                <div class="mu-testimonial-info">
                  <?php if ( ! empty( $image ) ) : ?>
                    <img class="mu-testimonial-img" src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $name ); ?>">
                  <?php else : ?>
                    <div class="mu-testimonial-avatar-placeholder">
                      <i class="fa fa-user"></i>
                    </div>
                  <?php endif; ?>
                  <h4><?php echo esc_html( $name ); ?></h4>
                  <?php if ( ! empty( $designation ) ) : ?>
                    <span><?php echo esc_html( $designation ); ?></span>
                  <?php endif; ?>
                </div>
              </div>
              <!-- end single testimonial item -->
            <?php 
                endif;
            } 
            ?>
          </div>
          <!-- end testimonial content -->
          
        </div>
      </div>
    </div>
  </div>
</section>
<!-- End Testimonials Section -->
<?php 
endif; 
?>
