<div class="modal" id="modal_iterations">
  <div class="modal-background js-modal" data-target="#modal_iterations"></div>
  <div class="modal-content">
    <div class="btn-close js-modal" data-target="#modal_iterations">
      <?php
      $cross_svg = trailingslashit(get_template_directory()) . 'dist/assets/svg/cross.svg';
      if (is_readable($cross_svg)) {
        include $cross_svg;
      } else {
        echo '<span aria-hidden="true">&times;</span>';
      }
      ?>
    </div>

    <?php
    // Initialize to avoid undefined variable notices when there are no rows
    $select = '';
    $list   = '';
    $imgs   = '';

    if (have_rows('iterations')) {
      $cpt = 0;

      while (have_rows('iterations')) {
        the_row();
        $titre = get_sub_field('titre');
        $desc  = get_sub_field('description');
        $image = get_sub_field('image');

        $select .= "<option id='iterationSelect{$cpt}' value='{$cpt}'>" . esc_html($titre) . "</option>";
        $list   .= '<div id="iterationList' . $cpt . '" class="iteration_list">' . (is_string($desc) ? $desc : '') . '</div>';

        if (is_array($image) && !empty($image['id'])) {
          $imgs .= wp_get_attachment_image((int)$image['id'], 'full', false, [
            'id'    => 'iterationImg' . $cpt,
            'class' => 'iteration_img',
            'alt'   => esc_attr($titre),
          ]);
        }
        $cpt++;
      }
    }
    ?>

    <div class="modal-body">
      <div class="col-left">
        <div class="modal-title uppercase text-uppercase"><?php echo __('Iterations', 'laurentperrier'); ?></div>
        <div class="custom_select_wrapper">
          <select id="selectIterations" class="selectIterations uppercase">
            <?php echo $select ?>
          </select>
        </div>
        <div class="modal-result text-uppercase">
          <h3><?php echo __('Blend of years :', 'laurentperrier'); ?></h3>
          <?php echo $list ?>
        </div>
      </div>
      <div class="col-right">
        <?php echo $imgs ?>
      </div>
    </div>
  </div>
</div>

<script>

</script>
<!-- MODALES STORE -->