Skip to content

Instantly share code, notes, and snippets.

@rutger1140
Created September 1, 2012 14:28
Show Gist options
  • Select an option

  • Save rutger1140/3574763 to your computer and use it in GitHub Desktop.

Select an option

Save rutger1140/3574763 to your computer and use it in GitHub Desktop.
Wordpress maintenance mode
<?php
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();
?>
@rutger1140

Copy link
Copy Markdown
Author

Use this file to put your Wordpress install in maintenance mode while keeping it available for logged in users, and keeping the wp-admin up.
Place it in your root with filename .maintenance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment