Quick maintenance mode

Quick maintenance mode

Sometimes, you need to put your blog on hold while performing some maintenance. Many plugins are allowing you to do so, but here is a simpler solution: Just paste the following snippet into your functions.php file and save it. Your blog is now unavailable to anyone except administrators. Don’t forget to remove the code when you’re done with maintenance!

function cwc_maintenance_mode() {

if ( !current_user_can( ‘edit_themes’ )   !is_user_logged_in() ) {

wp_die(‘Maintenance, please come back soon.’);

}

}

add_action(‘get_header’, ‘cwc_maintenance_mode’);