Last active
December 11, 2015 20:38
-
-
Save groucho75/4656182 to your computer and use it in GitHub Desktop.
Quick maintenance mode in WordPress. Only admin can browse the blog, other people get a maintenance message. Put this php file in /mu-plugins.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Quick maintenance mode in WordPress, using a bit of custom css and html | |
* | |
* Only admin can browse the blog, other people get a maintenance message | |
* | |
* Put this file in /wp-content/mu-plugins folder | |
*/ | |
function alo_maintenance_mode() { | |
if ( ! current_user_can( 'administrator' ) ) { | |
$html = ' | |
<style type="text/css"> | |
html { | |
/* E.g. force a custom background */ | |
/* background-color: #efefef !important; */ | |
} | |
#error-page { | |
/* Customize the message box: width, background... */ | |
} | |
/* E.g. put the message on right */ | |
#msg-alert { | |
display: block; | |
font: 20px verdana, arial, sans-serif; | |
position: relative; | |
text-align: right; | |
line-height: 110%; | |
color: #444444; | |
} | |
</style> | |
<!-- E.g. put here your logo, on left --> | |
<!-- Write your alert message --> | |
<span id="msg-alert"><strong>Maintenance Mode.</strong><br /><small>Please try back in a few hours.</small></span> | |
'; | |
wp_die( $html, 'Maintenance Mode | ' . get_bloginfo('name') ); | |
} | |
} | |
add_action('get_header', 'alo_maintenance_mode'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment