schema.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. $schemaGraph = [];
  3. // 1. Organization
  4. $schemaGraph[] = [
  5. "@type" => "Organization",
  6. "@id" => $currentUrl . "#organization",
  7. "name" => $seo['title'] ?? $pageContent['title'],
  8. "url" => $currentDomain,
  9. "logo" => !empty($settingsContent['header-logo']) ? $currentDomain . '/' . json_decode($settingsContent['header-logo'], true)['src'] : '',
  10. "sameAs" => !empty($settingsContent['official-sites']) ? json_decode($settingsContent['official-sites'], true) : []
  11. ];
  12. // 2. Casino Brand
  13. $casinoBrand = [
  14. "@type" => ["Casino", "Brand"],
  15. "@id" => $currentUrl . "#brand-casino-entity",
  16. "name" => $seo['title'],
  17. "url" => $seo['canonical'] ?? $currentUrl,
  18. "image" => !empty($settingsContent['header-logo']) ? $currentDomain . '/' . json_decode($settingsContent['header-logo'], true)['src'] : '',
  19. "aggregateRating" => [
  20. "@type" => "AggregateRating",
  21. "ratingValue" => "5",
  22. "ratingCount" => $settingsContent['rating-count'] ?? "150",
  23. "worstRating" => "1",
  24. "bestRating" => "5"
  25. ],
  26. "priceRange" => "$",
  27. "openingHoursSpecification" => [
  28. [
  29. "@type" => "OpeningHoursSpecification",
  30. "dayOfWeek" => ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
  31. "opens" => "00:00",
  32. "closes" => "23:59"
  33. ]
  34. ],
  35. "parentOrganization" => [
  36. "@id" => $currentUrl . "#organization"
  37. ]
  38. ];
  39. // Add address if any field is filled
  40. if (!empty($settingsContent['address-street']) || !empty($settingsContent['address-city']) ||
  41. !empty($settingsContent['address-region']) || !empty($settingsContent['address-postal']) ||
  42. !empty($settingsContent['address-country'])) {
  43. $casinoBrand["address"] = [
  44. "@type" => "PostalAddress",
  45. "streetAddress" => $settingsContent['address-street'] ?? '',
  46. "addressLocality" => $settingsContent['address-city'] ?? '',
  47. "addressRegion" => $settingsContent['address-region'] ?? '',
  48. "postalCode" => $settingsContent['address-postal'] ?? '',
  49. "addressCountry" => $settingsContent['address-country'] ?? ''
  50. ];
  51. }
  52. $schemaGraph[] = $casinoBrand;
  53. // 3. WebSite
  54. $schemaGraph[] = [
  55. "@type" => "WebSite",
  56. "url" => $currentDomain,
  57. "name" => $settingsContent['title-h1'],
  58. "publisher" => [
  59. "@id" => $currentUrl . "#organization"
  60. ]
  61. ];
  62. // 4. WebPage
  63. $schemaGraph[] = [
  64. "@type" => "WebPage",
  65. "@id" => $currentUrl . "#webpage",
  66. "name" => $seo['title'],
  67. "description" => $seo['description'],
  68. "inLanguage" => $seo['extra_fields']['locale'] ?? 'en',
  69. "url" => $currentUrl,
  70. "dateModified" => $settingsContent['modified-date'] ?? date('Y-m-d'),
  71. "author" => [
  72. "@type" => "Person",
  73. "name" => $settingsContent['author-name'] ?? '',
  74. "image" => !empty($settingsContent['author-img']) ? $currentDomain . '/' . $settingsContent['author-img'] : '',
  75. "jobTitle" => "Casino Expert"
  76. ],
  77. "publisher" => [
  78. "@id" => $currentUrl . "#organization"
  79. ]
  80. ];
  81. // 5. Review
  82. $schemaGraph[] = [
  83. "@type" => "Review",
  84. "itemReviewed" => [
  85. "@id" => $currentUrl . "#brand-casino-entity"
  86. ],
  87. "reviewRating" => [
  88. "@type" => "Rating",
  89. "ratingValue" => "5",
  90. "bestRating" => "5"
  91. ],
  92. "author" => [
  93. "@id" => $currentUrl . "#organization"
  94. ],
  95. "name" => $seo['title'],
  96. "reviewBody" => $seo['description'],
  97. "datePublished" => $settingsContent['published-date'] ?? date('Y-m-d')
  98. ];
  99. // 6. Offer (if bonus fields are filled)
  100. if (!empty($settingsContent['bonus-name']) || !empty($settingsContent['bonus-description'])) {
  101. $schemaGraph[] = [
  102. "@type" => "Offer",
  103. "@id" => $currentUrl . "#offer",
  104. "name" => $settingsContent['bonus-name'] ?? '',
  105. "description" => $settingsContent['bonus-description'] ?? '',
  106. "url" => $settingsContent['bonus-url'] ?? $currentUrl,
  107. "price" => $settingsContent['bonus-price'] ?? '',
  108. "priceCurrency" => $settingsContent['bonus-currency'] ?? 'EUR',
  109. "availability" => "https://schema.org/InStock",
  110. "eligibleCustomerType" => "https://schema.org/NewCustomer",
  111. "offeredBy" => [
  112. "@id" => $currentUrl . "#organization"
  113. ]
  114. ];
  115. }
  116. // 7. BreadcrumbList
  117. $schemaGraph[] = [
  118. "@type" => "BreadcrumbList",
  119. "itemListElement" => [
  120. [
  121. "@type" => "ListItem",
  122. "position" => 1,
  123. "name" => $settingsContent['title-h1'],
  124. "item" => $currentUrl
  125. ]
  126. ]
  127. ];
  128. // 8. FAQPage
  129. if (!empty($faqItems)) {
  130. $schemaGraph[] = [
  131. "@type" => "FAQPage",
  132. "mainEntityOfPage" => [
  133. "@id" => $currentUrl . "#webpage"
  134. ],
  135. "mainEntity" => array_map(function ($item) {
  136. return [
  137. "@type" => "Question",
  138. "name" => htmlspecialchars($item['question']),
  139. "acceptedAnswer" => [
  140. "@type" => "Answer",
  141. "text" => htmlspecialchars($item['answer'])
  142. ]
  143. ];
  144. }, $faqItems)
  145. ];
  146. }
  147. // 9. SoftwareApplication (if app fields are filled)
  148. if (!empty($settingsContent['app-download-url']) || !empty($settingsContent['app-install-url'])) {
  149. $schemaGraph[] = [
  150. "@type" => "SoftwareApplication",
  151. "@id" => $currentUrl . "#app",
  152. "name" => $settingsContent['title-h1'] . " App",
  153. "operatingSystem" => "Android, iOS",
  154. "applicationCategory" => "GameApplication",
  155. "provider" => [
  156. "@id" => $currentUrl . "#organization"
  157. ],
  158. "offers" => [
  159. "@type" => "Offer",
  160. "price" => "0",
  161. "priceCurrency" => "EUR",
  162. "availability" => "https://schema.org/InStock"
  163. ],
  164. "downloadUrl" => $settingsContent['app-download-url'] ?? '',
  165. "installUrl" => $settingsContent['app-install-url'] ?? '',
  166. "aggregateRating" => [
  167. "@type" => "AggregateRating",
  168. "ratingValue" => "5",
  169. "ratingCount" => $settingsContent['app-rating-count'] ?? "99",
  170. "worstRating" => "1",
  171. "bestRating" => "5"
  172. ],
  173. "author" => [
  174. "@id" => $currentUrl . "#organization"
  175. ]
  176. ];
  177. }
  178. // Generate final JSON-LD
  179. $schemaMarkup = [
  180. "@context" => "https://schema.org",
  181. "@graph" => array_filter($schemaGraph) // Remove null entries
  182. ];
  183. echo json_encode($schemaMarkup, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
  184. ?>