diff --git a/config/functions_site.php b/config/functions_site.php index 4476ad3..5abc3cf 100644 --- a/config/functions_site.php +++ b/config/functions_site.php @@ -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; +} diff --git a/site/includes/seo.php b/site/includes/seo.php index 8d4fca2..a50be38 100644 --- a/site/includes/seo.php +++ b/site/includes/seo.php @@ -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'] = [ diff --git a/site/index.php b/site/index.php index 4a2745d..bd75e07 100644 --- a/site/index.php +++ b/site/index.php @@ -18,7 +18,7 @@ $reviews = site_reviews(); // null when not configured / nothin ?>
- Ligar + Ligar Inscreve-te Já!
@@ -587,11 +587,11 @@ $session = session();
- +

- +