<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
global $avi_meta_title, $avi_meta_desc, $avi_schema_json,
       $avi_canonical, $avi_no_index, $avi_meta_image;
?>
<?php
// Hreflang SEO — EN/FR/ES
$avi_path = isset( $_SERVER['REQUEST_URI'] )
    ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) )
    : '/';
$avi_path_clean = preg_replace( '#^/(fr|es)/#', '/', $avi_path );
$avi_url_en = home_url( $avi_path_clean );
$avi_url_fr = home_url( '/fr' . ( $avi_path_clean === '/' ? '/' : $avi_path_clean ) );
$avi_url_es = home_url( '/es' . ( $avi_path_clean === '/' ? '/' : $avi_path_clean ) );
?>
<link rel="alternate" hreflang="en" href="<?php echo esc_url( $avi_url_en ); ?>">
<link rel="alternate" hreflang="fr" href="<?php echo esc_url( $avi_url_fr ); ?>">
<link rel="alternate" hreflang="es" href="<?php echo esc_url( $avi_url_es ); ?>">
<link rel="alternate" hreflang="x-default" href="<?php echo esc_url( $avi_url_en ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<?php
wp_head();
