Index of /andrejciho/Wordpress MU/Performing maintenance on WPMU

Name Last modified Comments Description

Back Parent Directory

Performing maintenance on WPMU

Recently I did an upgrade of WPMU 1.0 RC1 to 1.0 for a client. I was determined to do it right - without making anyone angry because they lost the post they were working on for the last 20 minutes and definitely without anyone seeing any errors. If you already have a procedure for this, great - otherwise you may consider this quick and easy solution.

First of all I put up an announcement into the admin interface half-a-day in advance (could have done couple days) so that anyone who logs in knows it's coming. WordPress MultiUser has a neat action hook called admin_notices which you can call in a plugin. So I put together this simple one:

<?php
add_action('admin_notices','displayAnnouncement');
function displayAnnouncement() {
  $msg = '
    <div style="background: #ff0000;color: #000000;font-size: 12pt;">
      <p>your message goes here</p>
    </div>
  ';
  echo trim($msg);
}
?>

Then I created an offline page that all the visitors would be redirected to, while I was working on the site. I just created a folder called "offline", copied the main page's theme (CSS and images) and whipped up a nice .html document (no PHP) telling users that the site is temporarily unavailable due to maintenance.

After all the users knew not to log in and the offline page was ready for the public, it was time for the redirect. The beauty in the following few lines of code is that it redirected everyone BUT me - so I could use and test the site all I wanted without anyone seeing any ugly unprofessional errors. So here goes what I inserted at the top of index.php, wp-admin/admin.php (included in all the admin pages) and wp-login.php. If you have wp-signup.php enabled, I'd put it there too.

<?php
$ip = $_SERVER['REMOTE_ADDR'];
if ('xxx.xxx.xxx.xxx' <> $ip ) {
  header('Location: http://your-WPMU-url/offline/');
  wp_redirect('http://your-WPMU-url/offline/');
}
?>

*Replace the xxx.xxx.xxx.xxx with your IP address.
**I used the wp_redirect just to be sure it works - you know, in case some other headers get passed before the regular redirect.

Now I was ready for the upgrade and maintenance. (Just a note - if you plan to overwrite any of the files that contain your custom redirect during your maintenance/upgrade, don't forget to include the redirect in the new ones as well :-) - at least until you are done with the maintenance.)


Leave a Comment
*Required
*Required (Never published)
 

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image