WordPress Maintenance
drkskwlkr |
PRO |
05/25/23 10:08:41 PM UTC (Edited) |
0 ⭐ |
1520 👁️ |
Never ⏰ |
[wordpress, maintenance]
<?php add_action('template_redirect', function () {
$secrete_pass = 'allow-access';
$maintenance_url = '/maintenance/';
$protocol = 'http://';
$user_is_admin = current_user_can('manage_options');
if ($user_is_admin) return;
if ( ($_GET['access'] ?? '') === $secrete_pass ) return;
if ( ($_SERVER['HTTPS'] ?? '') === 'on' || ($_SERVER['HTTPS'] ?? 0) === 1 || ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? 'http') === 'https' )
{
$protocol = 'https://';
}
$path = wp_make_link_relative( $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
if ( $path !== $maintenance_url ) exit( wp_redirect( home_url( $maintenance_url ), 307 ));
}
Comments