fix: telefones em formato internacional (+351) nos links tel: e no JSON-LD

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andreandClaude Opus 5.5 committed 2026-09-24 21:58:16 +01:00
1 parent 0587be7d14
commit 42f5919915
3 files changed
+15 -4

No files matched your search

+11
View File
@@ -126,3 +126,14 @@ function site_sitemap_urls(PDO $pdo): array {
}
return $urls;
}
// E.164 form for tel: links and structured data. Numbers are stored however
// the admin typed them ("964 201 137", "+351 231 451 346"); a bare 9-digit
// Portuguese number gets +351 so the link also works from a foreign phone.
function site_tel(?string $phone): string {
$p = preg_replace('/[^\d+]/', '', (string) $phone);
if ($p === '') return '';
if ($p[0] !== '+' && strlen($p) === 9) return '+351' . $p;
if ($p[0] !== '+' && str_starts_with($p, '00')) return '+' . substr($p, 2);
return $p;
}
+1 -1
View File
@@ -9,7 +9,7 @@ $ld = [
'image' => base_url('site/assets/img/home.jpg'),
'logo' => base_url('site/assets/img/logos/logo_black.svg'),
];
if (!empty($info['phone'])) $ld['telephone'] = $info['phone'];
if (!empty($info['phone'])) $ld['telephone'] = site_tel($info['phone']);
if (!empty($info['email'])) $ld['email'] = $info['email'];
if (!empty($info['adress'])) {
$ld['address'] = [
+3 -3
View File
@@ -18,7 +18,7 @@ $reviews = site_reviews(); // null when not configured / nothin
?>
<!-- Mobile sticky CTA bar -->
<div class="mobile-cta-bar">
<a href="tel:<?= htmlspecialchars(str_replace(' ', '', $info['phone'] ?? '')) ?>" class="cta-btn cta-btn-call"><i class="fas fa-phone-alt"></i> Ligar</a>
<a href="tel:<?= htmlspecialchars(site_tel($info['phone'] ?? '')) ?>" class="cta-btn cta-btn-call"><i class="fas fa-phone-alt"></i> Ligar</a>
<a href="#contactos" class="cta-btn cta-btn-cta smooth-scroll">Inscreve-te Já!</a>
</div>
@@ -587,11 +587,11 @@ $session = session();
<div class="contact-info text-center text-md-left">
<i class="fas fa-phone-volume"></i>
<div class="cf-text">
<a href="tel:<?= htmlspecialchars(str_replace(' ', '', $info['phone'] ?? '')) ?>">
<a href="tel:<?= htmlspecialchars(site_tel($info['phone'] ?? '')) ?>">
<p><?= htmlspecialchars($info['phone'] ?? '') ?></p>
</a>
<?php if (($info['telephone'] ?? '') !== ''): ?>
<a href="tel:<?= htmlspecialchars(str_replace(' ', '', $info['telephone'])) ?>">
<a href="tel:<?= htmlspecialchars(site_tel($info['telephone'])) ?>">
<p><?= htmlspecialchars($info['telephone']) ?></p>
</a>
<?php endif; ?>