<?php
/**
 * Social 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', 'right'.
 *   @type array  $share {
 *     @type bool   $share_facebook_enabled       True to enable Facebook share.
 *     @type bool   $share_x_enabled              True to enable X share.
 *     @type string $share_text                   Share text.
 *     @type string $share_url                    Share url.
 *   }
 * }
 */

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

$defaults = [
  'share' => [
    'share_facebook_enabled'  => false,
    'share_x_enabled'         => false
  ]
];

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

$share_enabled = $options['share']['share_facebook_enabled'] || $options['share']['share_x_enabled'];

$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;
  }
}

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

  /**
   * Social Links
   */
  orokublocks()->requireTemplate( 'includes/template/social-links', $options['share'] );
  
?>
</div>
<?php endif; ?>