Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Last active December 19, 2018 10:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damiencarbery/388652a791bfac7bbbdaf414ebdf4383 to your computer and use it in GitHub Desktop.
Save damiencarbery/388652a791bfac7bbbdaf414ebdf4383 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Maintenance Mode (Simple)
Plugin URI: http://www.damiencarbery.com
Description: Put site into maintenance mode for regular site visitors. Deactivate plugin to disable maintenance mode.
Author: Damien Carbery
Version: 0.3
*/
// Wait until 'wp' to allow login page to work.
add_action( 'wp', 'maintenance_mode' );
function maintenance_mode() {
if ( !is_user_logged_in() || !current_user_can( 'switch_themes' ) ) {
wp_die( get_bloginfo( 'Name' ) . ' is undergoing maintenance.' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment