Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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 ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement