// Dynamic WebPage Schema (Duplicate-Safe)
add_action('wp_head', function () {

  static $already_output = false;
  if ($already_output) return;
  $already_output = true;

  if (is_admin()) return;

  global $post;
  if (!$post) return;

  $page_url   = get_permalink($post);
  $page_title = wp_strip_all_tags(get_the_title($post));

  $data = [
    "@context" => "https://schema.org",
    "@type"    => "WebPage",
    "@id"      => $page_url . "#webpage",
    "url"      => $page_url,
    "name"     => $page_title,
    "isPartOf" => [
      "@id" => "https://baliecodeli.net/#website"
    ],
    "about" => [
      "@id" => "https://baliecodeli.net/#restaurant"
    ]
  ];
  ?>
<script type="application/ld+json">
<?php echo wp_json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); ?>
</script>
  <?php
}, 99); // Late priority so we can detect others first
