-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-mini-maintenance.php
65 lines (57 loc) · 1.37 KB
/
wp-mini-maintenance.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/*
Plugin Name: WP mini maintenance
Plugin URI: https://github.com/vivalamovie/wp-mini-maintenance
Description: The smallest WordPress maintenance plugin
Author: Christian Pier
Version: 1.0
Author URI: http://vlmsrv.com
License: https://creativecommons.org/publicdomain/zero/1.0/
*/
if(!function_exists('maintenance_head')):
function maintenance_head($status_header, $header, $text, $protocol) {
if ( !is_user_logged_in() ) {
return "$protocol 503 Service Unavailable";
}
}
endif;
if(!function_exists('maintenance_content')):
function maintenance_content() {
if ( !is_user_logged_in() ) {
$page = <<<EOT
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title></title>
<body></body>
</html>
EOT;
die($page);
}
}
endif;
if(!function_exists('maintenance_feed')):
function maintenance_feed() {
if ( !is_user_logged_in() ) {
die('<?xml version="1.0" encoding="UTF-8"?>'.
'<status>Service unavailable</status>');
}
}
endif;
if(!function_exists('add_feed_actions')):
function add_feed_actions() {
$feeds = array ('rdf', 'rss', 'rss2', 'atom');
foreach ($feeds as $feed) {
add_action('do_feed_'.$feed, 'maintenance_feed', 1, 1);
}
}
endif;
if (function_exists('add_filter') ):
add_filter('status_header', 'maintenance_head', 10, 4);
add_action('get_header', 'maintenance_content');
add_feed_actions();
else:
die('');
endif;
?>