=== Surf7 Simple Maintenance Mode ===
Contributors: surf7net
Tags: maintenance mode, under construction, site maintenance, maintenance
Requires at least: 5.0
Tested up to: 7.1
Requires PHP: 7.0
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Enable maintenance mode with one click. Logged-in users can view the site; others see a custom message or are redirected.

== Description ==

**Surf7 Simple Maintenance Mode** is a straightforward plugin that allows you to put your WordPress website into maintenance mode with just one click. When maintenance mode is enabled:

- Only logged-in users (any role) can access the frontend.
- Non-logged-in users will either see a predefined message or be redirected to a specific URL.

**Features:**

- **Easy Activation:** Enable or disable maintenance mode from the WordPress dashboard.
- **Custom Maintenance Message:** Set a personalized message to display to visitors.
- **Redirect Option:** Redirect visitors to another URL if desired.
- **Access Control:** Only logged-in users can view the site when maintenance mode is active.

**Use Cases:**

- Performing website updates or maintenance tasks.
- Launching a new website or making significant changes.
- Temporarily restricting access to the public.

The plugin does not connect to any external service and stores nothing beyond a single WordPress option.

== Installation ==

1. **Upload the Plugin Files:**

   - Upload the `surf7-simple-maintenance-mode` folder to the `/wp-content/plugins/` directory.
   - Alternatively, install the plugin through the WordPress plugins screen directly by navigating to **Plugins** > **Add New**, searching for "Surf7 Simple Maintenance Mode," and clicking **Install Now**.

2. **Activate the Plugin:**

   - Activate the plugin through the **Plugins** screen in WordPress.

3. **Configure the Settings:**

   - Go to **Settings** > **Maintenance Mode**.
   - Enable maintenance mode by checking the **Enable Maintenance Mode** option.
   - Set a custom maintenance message or specify a redirect URL.
   - Click **Save Changes**.

== Frequently Asked Questions ==

= How do I enable maintenance mode? =

- Navigate to **Settings** > **Maintenance Mode** in your WordPress dashboard.
- Check the **Enable Maintenance Mode** option.
- Click **Save Changes**.

= Can I customize the maintenance message? =

Yes. Set a custom message in the **Maintenance Message** field on the settings page. Basic HTML (links, bold, italic, lists, paragraphs and line breaks) is allowed.

= How do I redirect visitors to another URL? =

- Enter the full URL (including `http://` or `https://`) in the **Redirect URL** field on the settings page.
- Leave the field empty if you prefer to display the maintenance message instead.
- The URL must point to a different domain than your site. A URL on your own site is ignored, because it would cause a redirect loop.

= Will logged-in users be affected by maintenance mode? =

No. Logged-in users (any role) can access the site normally when maintenance mode is enabled.

= What HTTP status is sent to visitors? =

The maintenance message is served with a `503 Service Unavailable` status, which tells search engines the outage is temporary. The redirect option sends a `302 Found`.

== Screenshots ==

1. The maintenance mode settings page, where you can enable the mode, set a custom message, or specify a redirect URL.
2. An example of the maintenance message displayed to non-logged-in users.

== Changelog ==

= 1.1.0 =
* Redirects now use `wp_safe_redirect()` with a scoped `allowed_redirect_hosts` filter, instead of `wp_redirect()`.
* Added a guard against redirecting to your own domain, which caused a redirect loop.
* Send no-cache headers so page caches and browsers do not retain the maintenance response.
* Removed a redundant administrator-role check that blocked multisite super admins without the administrator role on a subsite.
* Settings are now unslashed and validated more strictly before saving, and a registered default is declared for the option.
* Tested up to WordPress 7.1.

= 1.0 =
* Initial release of Surf7 Simple Maintenance Mode.

== Upgrade Notice ==

= 1.1.0 =
Compatibility update for WordPress 7.1, safer redirect handling, and no-cache headers on the maintenance response.

= 1.0 =
First release.
