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:
1 parent
0587be7d14
commit
42f5919915
3 files changed
+15
-4
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user