Skip to content

Instantly share code, notes, and snippets.

@ansulev
Forked from digitalinkwell/maintenance-mode.php
Last active July 7, 2018 07:24
Show Gist options
  • Save ansulev/df9accba08667375bceff4e80092292a to your computer and use it in GitHub Desktop.
Save ansulev/df9accba08667375bceff4e80092292a to your computer and use it in GitHub Desktop.
Easy put WordPress in Maintenance Mode.
/*
* put this on the very bottom of the functions.php file of your theme
* or create manually .maintenance on your web root with desired message
*/
// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
if(!current_user_can('edit_themes') || !is_user_logged_in()){
wp_die('<h1 style="color:red">Website under Maintenance</h1><br />We are performing scheduled maintenance. We will be back online shortly!');
}
}
add_action('get_header', 'wp_maintenance_mode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment