\n";
$metadata .= '
' . $escape($title) . " — Trusted Magazine\n";
$metadata .= ' ' . "\n";
$metadata .= ' ' . "\n";
$metadata .= ' ' . "\n";
$properties = [
'og:type' => 'article', 'og:site_name' => 'Trusted Magazine',
'og:locale' => $isEnglish ? 'en_US' : 'fr_FR', 'og:title' => $title,
'og:description' => $description, 'og:url' => $url,
'og:image' => $image, 'og:image:secure_url' => $image, 'og:image:alt' => $title,
];
if ($dimensions !== false) {
$properties['og:image:width'] = (string) $dimensions[0];
$properties['og:image:height'] = (string) $dimensions[1];
}
foreach ($properties as $property => $value) {
$metadata .= ' ' . "\n";
}
foreach (['twitter:card' => 'summary_large_image', 'twitter:title' => $title,
'twitter:description' => $description, 'twitter:image' => $image] as $name => $value) {
$metadata .= ' ' . "\n";
}
$structured = ['@context' => 'https://schema.org', '@type' => 'Article',
'headline' => $title, 'description' => $description, 'image' => $image,
'inLanguage' => $language, 'datePublished' => '2026-10-13',
'author' => ['@type' => 'Person', 'name' => $author],
'publisher' => ['@type' => 'Organization', 'name' => 'Trusted Magazine'],
'mainEntityOfPage' => $url];
$metadata .= '\n";
$headEnd = strpos($page, '');
if ($headEnd !== false) {
$head = substr($page, 0, $headEnd);
$head = preg_replace('~]*>.*?\s*~is', '', $head);
$head = preg_replace('~]*(?:name|property)=["\x27](?:description|author|og:[^"\x27]*|twitter:[^"\x27]*)["\x27][^>]*>\s*~is', '', $head);
$head = preg_replace('~]*charset=["\x27][^"\x27]*["\x27][^>]*>\s*~is', '', $head);
$head = preg_replace('~]*rel=["\x27]canonical["\x27][^>]*>\s*~is', '', $head);
$head = preg_replace_callback('~]*>~i', static function ($match) use ($metadata) {
return $match[0] . $metadata;
}, $head, 1);
$head = preg_replace('~~i', '', $head, 1);
$page = $head . substr($page, $headEnd);
}
}
header('Content-Type: text/html; charset=utf-8');
header('Cache-Control: no-cache, max-age=0, must-revalidate');
echo $page;