<?php
/**
 * Status Tag - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $icon             Custom SVG icon name.
 *   @type bool   $enabled          True to show tick, false to show minus.
 *   @type bool   $outline          True to show outline, false otherwise.
 *   @type bool   $background       True to add a background, false otherwise.
 *   @type bool   $radius           True to add soft border radius, false otherwise.
 *   @type string $size             Status tag size: One of: 'regular', 'small'. Default: 'regular'.
 * }
 */

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

$defaults = [
  'enabled' => true,
  'icon'    => '',
  'size'    => 'regular'
];

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

$wrapper_classes = [
  'orokublocks-status-tag'
];

if ( array_key_exists( 'size', $options ) ) {
  $wrapper_classes[] = 'orokublocks-status-tag--size--' . $options['size'];
}

if ( array_key_exists( 'enabled', $options ) ) {
  if ( $options['enabled'] ) {
    $wrapper_classes[] = 'orokublocks-status-tag--enabled';
  } else {
    $wrapper_classes[] = 'orokublocks-status-tag--disabled';
  }
}

if ( $options['icon'] !== '' ) {
  $icon_name = $options['icon'];
} else {
  $icon_name = $options['enabled'] ? 'check' : 'minus';
}

if ( array_key_exists( 'outline', $options ) ) {
  $wrapper_classes[] = 'orokublocks-status-tag--style--outline';
}

if ( array_key_exists( 'background', $options ) ) {
  $wrapper_classes[] = 'orokublocks-status-tag--style--background';
}

if ( array_key_exists( 'radius', $options ) ) {
  $wrapper_classes[] = 'orokublocks-status-tag--style--radius';
}

?>
<div class="<?php echo esc_attr( implode( ' ', $wrapper_classes ) ); ?>">
<?php

  /**
   * SVG
   */
  orokublocks()->requireTemplate(
    'includes/template/svg',
    [
      'additional_wrapper_classes'  => 'orokublocks-status-tag__icon',
      'icon'                        => $icon_name
    ]
  );
  
?>
</div>