enable_maintenance_mode

Filters whether to enable maintenance mode.

Description

apply_filters( 'enable_maintenance_mode', (bool) $true, (int) $upgrading ); 

This filter runs before it can be used by plugins. It is designed for non-web runtimes. If this filter returns true, maintenance mode will be active and the request will end. If false, the request will be allowed to continue processing even if maintenance mode should be active.

Parameters (2)

0. $true (bool) => true
Whether to enable maintenance mode. Default true.
1. $upgrading (int)
The timestamp set in the .maintenance file.

Usage

To run the hook, copy the example below.
  1. $true = apply_filters( 'enable_maintenance_mode', $true, $upgrading ); 
  2.  
  3. if ( !empty( $true ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the enable_maintenance_mode callback 
  2. function filter_enable_maintenance_mode( $true, $upgrading ) { 
  3. // make filter magic happen here... 
  4. return $true
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'enable_maintenance_mode', 'filter_enable_maintenance_mode', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'enable_maintenance_mode', 'filter_enable_maintenance_mode', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/load.php  
  1. if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) {