Maintenance Mode

To temporarily disable your site for maintenance we recommend using the Maintenance Mode plugin. Please note, this is plugin is meant to provide a temporary means of hiding your site. It is not intended to fully restrict access to site content.

Usage

On the VIP Go platform
To install and activate the plugin, you will have to follow these steps:

1. Commit the plugin to your repo. Add it to the Plugins directory, and ensure that the directory is named maintenance-mode.
2. Add the VIP_MAINTENANCE_MODE constant to vip-config/vip-config.php or in your theme and set to true.

 define( 'VIP_MAINTENANCE_MODE', true );

3. Load the plugin in client-mu-plugins/plugin-loader.php

wpcom_vip_load_plugin( 'maintenance-mode' );

On the WordPress.com VIP platform
The maintenance mode plugin is enabled by default. To activate the plugin, simply:

1. Add the VIP_MAINTENANCE_MODE constant to your theme and set to true
2. Load the plugin in your theme

define( 'VIP_MAINTENANCE_MODE', true );
...
// And be sure to load the plugin itself!
wpcom_vip_load_plugin( 'maintenance-mode' );

Regardless of the platform you’re on, please remember to always test locally before committing your code or submitting your PR to us for review. Once this code has been committed, you can open a browser page which you are not logged-in to view the maintenance mode page.

IMPORTANT: if you’re not seeing maintenance mode enabled on the frontend of your site, check the (WordPress.com) logged-in vs. logged-out experience…they’re different, by design! In the backend, you won’t see much as this is a code-only plugin.

Custom Template

To add a custom template / 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(s) you want to show your visitors.
  • Note: the template should include wp_head() and wp_footer() calls. You can find an example file here.

Additional Configurations

Using filters and conditionals, you can customize the behavior of the Maintenance Mode plugin based on your needs. Below are a few examples. Please note, these rely on the plugin being installed as described above.

Selectively Load Maintenance Mode
You can configure Maintenance Mode so that it will only display for a particular subsite. Note that this code would have to live in 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
You can also configure Maintenance Mode to keep the WordPress REST API enabled even though the rest of the site is not accessible. Note that this code would usually live in a file within the client-mu-plugins folder:

// 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;
             }
 
	return true;
}

Ready to get started?

Drop us a note.

No matter where you are in the planning process, we’re happy to help, and we’re actual humans here on the other side of the form. 👋 We’re here to discuss your challenges and plans, evaluate your existing resources or a potential partner, or even make some initial recommendations. And, of course, we’re here to help any time you’re in the market for some robust WordPress awesomeness.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.