<?php
/**
 * Rating Tag Box - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type array  $position                         Absolute position offset. Accepted values: 'top', 'top--overlayed', 'center', 'right', 'left'.
 *   @type array  $spacing                          Spacing classes. Accepted values: 'bottom'.
 *   @type int    $score_value                      Score value.
 *   @type int    $score_max_value                  Score max value.
 * }
 */

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

$defaults = [];

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

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

if ( array_key_exists( 'position', $options ) ) {
  $wrapper_classes[] = 'orokublocks-tag-box--position--absolute';

  foreach ( $options['position'] as $offset ) {
    $wrapper_classes[] = 'orokublocks-tag-box--position--' . $offset;
  }
}

if ( array_key_exists( 'spacing', $options ) ) {
  foreach ( $options['spacing'] as $direction ) {
    $wrapper_classes[] = 'orokublocks-tag-box--spacing--' . $direction;
  }
}

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

  /**
   * Rating
   */
  orokublocks()->requireTemplate(
    'includes/template/rating',
    [
      'rating_value'      => $options['score_value'],
      'rating_max_value'  => $options['score_max_value'],
      'size'              => 'small'
    ]
  );
  
?>
</div>