Start by creating a file in the root of your WordPress install (on level with wp-settings.php) called .maintenance
This file should contain the following:
(Note that this code allows admin users to login an access the blog/website.)
<?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(); ?>
If you want to specifiy a set time for the maintenance mode to display, you can replace the line:
<?php $upgrading = time(); ?>
With this code which has a unix timestamp:
<?php $upgrading = 1234567890; ?>
Read more about unix timestamps here:
http://www.onlineconversion.com/unix_time.htm
After wp-settings.php determines whether or not to put the blog into maintenance mode it checks to see if there is a file titled maintenance.php located in WP_CONTENT_DIR which is by default wp-content/.
Simply create a file at wp-content/maintenance.php containing the code you want to display the for the maintenance page. Below is a sample of code based off of the default maintenance page.
<?php /* Tell search engines that the site is temporarily unavilable */ $protocol = $_SERVER["SERVER_PROTOCOL"]; if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0'; header( "$protocol 503 Service Unavailable", true, 503 ); header( 'Content-Type: text/html; charset=utf-8' ); header( 'Retry-After: 600' ); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>RiAus - Maintenance</title> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style></head> <body> <div align="center"><img src="http://www.riaus.org.au/images/website-maintenance.png" alt="RiAus" width="700" height="380" border="0" usemap="#Map" /> </div><!-- end #content-outer --> <?php /* This passes control back to the wordpress upgrade routine */ die(); /* Don't change this */ ?>
Matt Sivel wrote an awesome 3 part blog on maintenance mode in WordPress:
http://sivel.net/2009/06/wordpress-maintenance-mode-without-a-plugin/
Revisions
There are no revisions for this post.
No comments yet.