Option to put site in maintenance mode

Add an option in “Settings > General” with a meta box to put the site in maintenance mode and add a message that uses the site’s theme.


Read-only archive: https://petitions.classicpress.net/posts/167/option-to-put-site-in-maintenance-mode

Author: qwow5

Vote count: 29

Status: open

Tags:

  • difficulty-moderate
  • request-add-feature

Comments

Yes please.

I am possibly misinterpreting this.
If a site is in maintenance mode it is unusable for either viewing or editing?
If I have a problem on a live site, client messed up a page, deleted menu etc. I would use an “under construction” plugin, with custom page while repairs are done.

That’s what this petition asks for, without a plugin.

The most difficult part is to agree on how an “under construction” site have to look.
Some templates have their own option, many plugins show fancy(?) countdowns, others contact forms.

Usually I create a custom HTML page and then redirect not logged in users to that page:

add_action('template_redirect', 'xsx_redirect_page');
function xsx_redirect_page() {
	if (is_user_logged_in()) {
		return;
	}
	if (defined('WP_CLI') && WP_CLI) {
		return;
	}
	$allowed_pages = [7966]; // 7966 is login page
	if (!in_array(get_queried_object_id(), $allowed_pages)) {
		wp_redirect('https://xxx.com/uc.html', 307);
		exit();
	}
}

As there are many ways people want a maintenance mode to work this should remain plugin territory.

I think a simple maintenance mode in the core would be good. All our hosting customers have that option under Settings > General. It’s a dropdown where they can select disabled, coming soon, and under maintenance. It’s important to differentiate between the two because they have different status codes to help search engines understand what’s going on. The actual page is basically what you get when you use wp_die(). Very simple, no fuss.

I agree, especially if it can be done essentially by leveraging code that’s already in core (like maintenance mode when updating). Do you have some code which you could use for a possible PR?