<?php
/**
 * Social Links - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type bool     $share_facebook_enabled       True to display facebook share, false otherwise.
 *   @type bool     $share_x_enabled              True to display x share, false otherwise.
 *   @type string   $share_text       Share text.
 *   @type string   $share_url        Share URL.
 * }
 */

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

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

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

$social_links = [
  'facebook'  => $options['share_facebook_enabled'],
  'x'         => $options['share_x_enabled']
];

?>
<div class="orokublocks-social-links">
<?php

  foreach ( $social_links as $social_network_name => $social_network_enabled ) {
    if ( $social_network_enabled ) {
      $social_link_args = [
        'name'  => $social_network_name
      ];

      if ( array_key_exists( 'share_text', $options ) ) {
        $social_link_args['share_text'] = $options['share_text'];
      }

      if ( array_key_exists( 'share_url', $options ) && ( $options['share_url'] !== '#' ) ) {
        $social_link_args['share_url'] = $options['share_url'];
      }

      /**
       * Social Link
       */
      orokublocks()->requireTemplate( 'includes/template/social-link', $social_link_args );
    }
  }

?>
</div>
