<?php
// AVI_VERSION: 1.0.1 | privacy-policy | 2026-04-30
defined( 'ABSPATH' ) || exit;
$avi_lang = 'en';
if ( function_exists( 'avi_get_current_lang' ) ) { $avi_lang = avi_get_current_lang(); }
if ( $avi_lang === 'en' && isset( $_SERVER['REQUEST_URI'] ) ) {
    $req = $_SERVER['REQUEST_URI'];
    if ( strpos( $req, '/fr/' ) === 0 ) { $avi_lang = 'fr'; }
    elseif ( strpos( $req, '/es/' ) === 0 ) { $avi_lang = 'es'; }
}
if ( $avi_lang !== 'en' ) { set_query_var( 'avi_lang', $avi_lang ); }
$is_fr = ( $avi_lang === 'fr' );
$is_es = ( $avi_lang === 'es' );

if ( ! class_exists( 'Avision_Page_Template' ) ) {
	require_once AVISION_PLUGIN_DIR . 'includes/class-avision-page-template.php';
}

global $avi_meta_title, $avi_meta_desc;
$avi_meta_title = 'Privacy Policy — Avision';
$avi_meta_desc  = 'How Avision collects, uses, and protects your data. GDPR compliant. Advantage Synergies LLP, London.';

Avision_Page_Template::render(
	'privacy-policy',
	array(
		'badge' => 'Legal',
		'title' => 'Privacy Policy',
		'sub'   => 'Advantage Synergies LLP — Registered in England & Wales, London',
		'align' => 'center',
		'size'  => 'small',
	),
	static function () {
		global $post;
		if ( ! ( $post instanceof \WP_Post ) ) {
			$post = get_queried_object();
		}
		?>
		<?php
		$raw = ( $post instanceof \WP_Post )
			? $post->post_content
			: '';

		if ( $raw ) {
			$clean = preg_replace( '/<style\b[^>]*>.*?<\/style>/is', '', $raw );
			$clean = preg_replace( '/<\/?(html|head|body)[^>]*>/i', '', (string) $clean );
			$clean = preg_replace( '/<!DOCTYPE[^>]*>|<(meta|title|link)[^>]*\/?>/i', '', (string) $clean );
			$clean = preg_replace( '/<!--\s*\/?wp:[^>]*-->/i', '', (string) $clean );
			$clean = trim( (string) $clean );
		} else {
			$clean = '';
		}
		?>
		<section class="avi-content-section">
			<div class="avi-content-block">
				<div class="avi-wp-content">
					<?php if ( $clean ) : ?>
						<?php echo wp_kses_post( $clean ); ?>
					<?php else : ?>
						<p style="color:var(--avi-text-muted,#A0B4D0)">
							Content available soon.
						</p>
					<?php endif; ?>
				</div>
				<p style="margin-top:32px;font-size:13px;
						  color:var(--avi-text-muted,#A0B4D0);
						  border-top:1px solid rgba(255,255,255,0.07);
						  padding-top:20px">
					Last updated: April 2026 · Governing law: England &amp; Wales ·
					<a href="/contact/" style="color:var(--avi-primary-light,#6B9FE8)">Contact us</a>
				</p>
			</div>
		</section>
		<?php
	}
);

