<?php
/**
 * Tag - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $text             Tag text.
 *   @type string $link             Tag link.
 *   @type string $color            Tag color.
 *   @type string $size             Tag size.
 * }
 */

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

$defaults = [
  'text'  => '',
  'link'  => '',
  'color' => '',
  'size'  => ''
];

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

?>
<?php if ( $options['link'] !== '' ) : ?>
  <a
    class="orokublocks-tag<?php if ( $options['size'] !== '' ) : ?> orokublocks-tag--size--<?php echo esc_attr( $options['size'] ); ?><?php endif; ?>"
    href="<?php echo esc_url( $options['link'] ); ?>"
    style="background-color: <?php echo esc_attr( $options['color'] ); ?>"
  >
  <?php echo esc_html( $options['text'] ); ?>
  </a>
<?php else: ?>
  <p
    class="orokublocks-tag<?php if ( $options['size'] !== '' ) : ?> orokublocks-tag--size--<?php echo esc_attr( $options['size'] ); ?><?php endif; ?>"
    style="background-color: <?php echo esc_attr( $options['color'] ); ?>"
  >
  <?php echo esc_html( $options['text'] ); ?>
  </p>
<?php endif; ?>