<?php
/**
 * Detail List - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $style                  Feature list style, one of: 'row', 'column'. Default: 'row'.
 *   @type array  $details               {
 *     @type string $title          Detail title.
 *     @type string $text           Detail text.
 *     @type string $text_link      Detail text link.
 *   }
 * }
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
  exit;
}

$defaults = [
  'style'   => 'row',
  'details' => []
];

$options = array_merge( $defaults, $args );

$wrapper_classes = [
  'orokublocks-detail-list'
];

if ( $options['style'] !== '' ) {
  $wrapper_classes[] = 'orokublocks-detail-list--style--' . $options['style'];
}

?>
<?php if ( count( $options['details'] ) > 0 ) : ?>
  <div class="<?php echo esc_attr( implode( ' ', $wrapper_classes ) ); ?>">
  <?php foreach ( $options['details'] as $detail ) : ?>
    <div class="orokublocks-detail-item">
    <?php if ( $detail['title'] !== '' ) : ?>
      <p class="orokublocks-detail-item__title"><?php echo esc_html( $detail['title'] ); ?></p>
    <?php endif; ?>
      <p class="orokublocks-detail-item__text">
      <?php if ( $detail['text_link'] !== '' ) : ?>
        <a class="orokublocks-pretty-link" href="<?php echo esc_url( $detail['text_link'] ); ?>">
      <?php endif; ?>
      <?php echo esc_html( $detail['text'] ); ?>
      <?php if ( $detail['text_link'] !== '' ) : ?>
        </a>
      <?php endif; ?>
      </p>
    </div>
  <?php endforeach; ?>
  </div>
<?php endif; ?>