<?php
// facebook.php (include)
// Requiere que exista $facebook (por ejemplo desde concha.php)

$facebook_url = isset($facebook) ? trim($facebook) : '';
if ($facebook_url != '') {
    // Normalizar a https
    if (stripos($facebook_url, 'http://') === 0) {
        $facebook_url = 'https://' . substr($facebook_url, 7);
    } elseif (stripos($facebook_url, 'https://') !== 0) {
        $facebook_url = 'https://' . ltrim($facebook_url, '/');
    }
}
?>
<!-- Bootstrap (opcional si ya lo tenés cargado en la página principal) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">

<?php if ($facebook_url == '') { ?>
  <div class="alert alert-warning mb-0">No está definida la variable <b>$facebook</b>.</div>
<?php } else { ?>
  <div id="fb-root"></div>
  <script async defer crossorigin="anonymous"
    src="https://connect.facebook.net/es_LA/sdk.js#xfbml=1&version=v19.0">
  </script>

  <div class="fb-page"
       data-href="<?php echo htmlspecialchars($facebook_url, ENT_QUOTES, 'UTF-8'); ?>"
       data-tabs="timeline"
       data-width="500"
       data-height="750"
       data-small-header="false"
       data-adapt-container-width="true"
       data-hide-cover="false"
       data-show-facepile="true">
    <blockquote cite="<?php echo htmlspecialchars($facebook_url, ENT_QUOTES, 'UTF-8'); ?>" class="fb-xfbml-parse-ignore">
      <a href="<?php echo htmlspecialchars($facebook_url, ENT_QUOTES, 'UTF-8'); ?>" target="_blank">Facebook</a>
    </blockquote>
  </div>
<?php } ?>