Last active
August 29, 2015 14:08
-
-
Save pfernandez/42d611537ed6e41c6ac0 to your computer and use it in GitHub Desktop.
Drop this snippet into the top of functions.php to get a simple maintenance mode without a separate plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show a special message to non-whitelisted users instead of the regular site. | |
* To activate maintenance mode, uncomment the add_action() line below. | |
*/ | |
//add_action('wp_head', 'simple_maintenance_mode'); | |
function simple_maintenance_mode() { | |
$user_name = wp_get_current_user()->user_login; | |
$ip = $_SERVER['REMOTE_ADDR']; | |
$user_is_dev = ( | |
current_user_can( 'update_themes' ) | |
// || $user_name == 'test1' | |
// || $ip == '00.000.000.000' | |
); | |
if( ! $user_is_dev ) { | |
?> | |
</head> | |
<body> | |
<div style="margin: 100px auto; width: 450px; text-align: center;"> | |
<h1 style="font-size: 100px; margin-bottom: 50px;">Sit tight.</h1> | |
<h2>We're upgrading and will be back on line soon.</h2> | |
</div> | |
</body> | |
<?php | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment