Skip to content

Commit

Permalink
Merge pull request #49 from Automattic/update-readme
Browse files Browse the repository at this point in the history
Migrating plugin instructions from old VIP Docs site to plugin's README.md
  • Loading branch information
yolih authored Jan 16, 2023
2 parents e0a3b89 + eb1e6b2 commit 6bcff2d
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,55 @@
[![Run PHPUnit and PHPCS](https://github.com/Automattic/maintenance-mode-wp/actions/workflows/integrate.yml/badge.svg)](https://github.com/Automattic/maintenance-mode-wp/actions/workflows/integrate.yml)

# Maintenance Mode

Shut down your site for a little while and do some maintenance on it!

Usage:
## Installation and activation

1. Add the plugin to the `/plugins` directory of an application's GitHub repository.
2. Define the `VIP_MAINTENANCE_MODE` constant as true in `vip-config/vip-config.php`.
3. Activate the plugin in the WordPress Admin dashboard Plugins screen.

### Custom Template

To add a custom template and messaging:

- Add a template to your theme's root folder called `template-maintenance-mode.php`.
- This should be a simple HTML page that should include the message you want to show your visitors.
- Create a template in your theme's root folder named `template-maintenance-mode.php`.
- This should be a simple HTML page that includes the message you want to show your visitors.
- Note: the template should include `wp_head()` and `wp_footer()` calls.
- Add the `VIP_MAINTENANCE_MODE` constant to your theme and set to `true`.

## Installation
### Additional Configurations

Using filters and conditionals, you can customize the behavior of the Maintenance Mode plugin based on your needs. These options rely on the plugin being installed as described above.

**Selectively Load Maintenance Mode**
Configure Maintenance Mode to only display for a specific network site. Code similar to this example must be added to the `vip-config/vip-config.php` file:

$site_name = $_SERVER['SERVER_NAME'];
$lockdown = false;

if ( false !== strpos( $site_name, 'url-to-enable-maintentance-mode' ) ) {
// Set lockdown
$lockdown = true;
}
// Set maintenance plugin
define( 'VIP_MAINTENANCE_MODE', $lockdown );

**Enable WordPress REST API**
Configure Maintenance Mode to keep the WordPress REST API enabled even though the rest of the site is not accessible. Note that this code should be added to a file located within the `client-mu-plugins` directory:

// Generally allow API access
add_filter( 'vip_maintenance_mode_restrict_rest_api', '__return_false' );

You can also choose to enable the REST API only in more narrow use-cases:

add_filter( 'vip_maintenance_mode_restrict_rest_api', 'x_mm_allow_api' );

function x_mm_allow_api( $default ) {
if (my_check() ) {
return false;
}

1. Install the plugin.
1. Set the `VIP_MAINTENANCE_MODE` constant to true.
1. Activate.
return true;
}

## Default template screenshots

Expand Down

0 comments on commit 6bcff2d

Please sign in to comment.