<?php
/**
 * Feature Box - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $theme            Feature box theme. Optional. Default: 'highlight'.
 *   @type string $title            Feature box title.
 *   @type string $text             Feature box text.
 *   @type string $image_url        Feature box image url.
 *   @type array  $links {
 *      @type string $name    Link name.
 *      @type string $href    Link href.
 *      @type string $target  Link target.
 *   }
 * }
 */

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

$defaults = [
  'theme'     => 'highlight',
  'image_url' => '',
  'links'     => []
];

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

?>
<div class="oroku-box-wrapper oroku-box-wrapper--padding--top">
  <div class="oroku-box-wrapper__decoration oroku-box-wrapper__decoration--theme--<?php echo esc_attr( $options['theme'] ); ?> oroku-box-wrapper__decoration--position--top">
  <?php

    /**
     * SVG
     */
    orokublocks()->admin->requireTemplate(
      'svg',
      [
        'icon'  => 'squiggly-texture'
      ]
    );

  ?>
  </div>

  <article class="oroku-box-wrapper__content oroku-feature-box">
    <div class="oroku-feature-box__details">
      <p class="oroku-feature-box__counter"><?php echo esc_html( strtoupper( orokublocks()->name ) ); ?></p>
      <h2 class="oroku-feature-box__title"><?php echo esc_html( $options['title'] ); ?></h2>
      <p class="oroku-feature-box__text oroku-paragraph">
      <?php

        echo wp_kses(
          $options['text'],
          [
            'strong'  => []
          ]
        );

      ?>
      </p>
    </div>

  <?php if ( $options['image_url'] !== '' ) : ?>
    <img  
      class="oroku-feature-box__image"
      src="<?php echo esc_url( $options['image_url'] ); ?>"
      alt=""
      width="458"
    >
  <?php endif; ?>
  </article>

<?php if ( count( $options['links'] ) > 0 ) : ?>
  <div class="oroku-box-wrapper__footer">
  <?php foreach ( $options['links'] as $link ) : ?>
    <a 
      class="oroku-button oroku-button--theme--primary"
      href="<?php echo esc_url( $link['href'] ); ?>"
    <?php if ( array_key_exists( 'target', $link ) ) : ?>
      target="<?php echo esc_attr( $link['target'] ); ?>"
    <?php endif; ?>
    >
    <?php echo esc_html( $link['name'] ); ?>
    </a>
  <?php endforeach; ?>
  </div>
<?php endif; ?>
</div>