<?php
/**
 * Card Footer - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $title                        Footer title.
 *   @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.
 *   }
 *   @type string $theme                        Footer theme. Accepted values: 'light', 'dark'. Default: 'dark'.
 * }
 */

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

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

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

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

?>
<?php if ( ( $options['title'] !== '' ) || $share_enabled ) : ?>
<div class="orokublocks-card__content orokublocks-card__content--bordered orokublocks-card__content--adjacent orokublocks-card__content--adjacent--small<?php if ( $options['theme'] === 'dark' ) : ?> orokublocks-card__content--theme--darker<?php endif; ?>">
  <div class="orokublocks-card__item orokublocks-card__item--divided orokublocks-card__item--gap<?php if ( $options['title'] === '' ) : ?> orokublocks-card__item--justify--center<?php else: ?> orokublocks-card__item--justify--space--between<?php endif; ?>">
  <?php if ( $options['title'] !== '' ) : ?>
    <div class="orokublocks-card__item">
      <p class="orokublocks-card__text orokublocks-card__text--size--small"><?php echo esc_html( $options['title'] ); ?></p>
    </div>
  <?php endif; ?>

    <div class="orokublocks-card__item">
    <?php

      if ( $share_enabled ) {
        /**
         * Social Links
         */
        orokublocks()->requireTemplate( 'includes/template/social-links', $options['share'] );
      }

    ?>
    </div>
  </div>
</div>
<?php endif; ?>