<?php
/**
 * Card Footer - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $title                        Footer left title.
 *   @type string $title_style                  Footer left title style. One of: 'bold'.
 *   @type string $share_title                  Footer share 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'       => '',
  'title_style' => '',
  'share_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 if ( $options['title_style'] === 'bold' ) : ?> orokublocks-card__text--style--bold<?php endif; ?>"><?php echo esc_html( $options['title'] ); ?></p>
    </div>
  <?php endif; ?>

    <div class="orokublocks-card__item<?php if ( $options['share_title'] !== '' ) : ?> orokublocks-card__item--divided orokublocks-card__item--gap--mini orokublocks-card__item--align--center<?php endif; ?>">
    <?php if ( $options['share_title'] !== '' ) : ?>
      <div class="orokublocks-card__item">
        <p class="orokublocks-card__text orokublocks-card__text--size--small"><?php echo esc_html( $options['share_title'] ); ?></p>
      </div>
    <?php endif; ?>
    <?php

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

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