Skip to content

Instantly share code, notes, and snippets.

@rogerbuecker-snippets
Created October 12, 2012 11:46
Show Gist options
  • Save rogerbuecker-snippets/3878847 to your computer and use it in GitHub Desktop.
Save rogerbuecker-snippets/3878847 to your computer and use it in GitHub Desktop.
Wordpress: Smart Wordpress Maintenance Mode
<?php
/**
* Place this file in root of wordpress site to enable
* maintenance mode for users who are not logged in.
* Also, allows access to /wp-admin during maintenance
*
* Filename: .maintenance
*/
function is_user_logged_in() {
$loggedin = false;
foreach ( (array) $_COOKIE as $cookie => $value ) {
if ( stristr($cookie, 'wordpress_logged_in_') )
$loggedin = true;
}
return $loggedin;
}
if ( ! stristr($_SERVER['REQUEST_URI'], '/wp-admin') && ! stristr($_SERVER['REQUEST_URI'], '/wp-login.php') && ! is_user_logged_in() )
$upgrading = time();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment