189 | | if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) { |
190 | | return; |
191 | | } |
192 | | |
193 | | global $upgrading; |
194 | | |
195 | | require ABSPATH . '.maintenance'; |
196 | | // If the $upgrading timestamp is older than 10 minutes, don't die. |
197 | | if ( ( time() - $upgrading ) >= 600 ) { |
198 | | return; |
199 | | } |
200 | | |
201 | | /** |
202 | | * Filters whether to enable maintenance mode. |
203 | | * |
204 | | * This filter runs before it can be used by plugins. It is designed for |
205 | | * non-web runtimes. If this filter returns true, maintenance mode will be |
206 | | * active and the request will end. If false, the request will be allowed to |
207 | | * continue processing even if maintenance mode should be active. |
208 | | * |
209 | | * @since 4.6.0 |
210 | | * |
211 | | * @param bool $enable_checks Whether to enable maintenance mode. Default true. |
212 | | * @param int $upgrading The timestamp set in the .maintenance file. |
213 | | */ |
214 | | if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) { |
| 184 | // Return if maintenance mode is disabled. |
| 185 | if ( ! wp_in_maintenance_mode() ) { |
| 249 | /** |
| 250 | * Check if maintenance mode is enabled. |
| 251 | * |
| 252 | * Checks for a file in the WordPress root directory named ".maintenance". |
| 253 | * This file will contain the variable $upgrading, set to the time the file |
| 254 | * was created. If the file was created less than 10 minutes ago, WordPress |
| 255 | * is in maintenance mode. |
| 256 | * |
| 257 | * @since 5.5.0 |
| 258 | * |
| 259 | * @return bool |
| 260 | */ |
| 261 | function wp_in_maintenance_mode() { |
| 262 | if ( ! file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) { |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | global $upgrading; |
| 267 | |
| 268 | require ABSPATH . '.maintenance'; |
| 269 | // If the $upgrading timestamp is older than 10 minutes, consider maintenance over. |
| 270 | if ( ( time() - $upgrading ) >= 600 ) { |
| 271 | return false; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Filters whether to enable maintenance mode. |
| 276 | * |
| 277 | * This filter runs before it can be used by plugins. It is designed for |
| 278 | * non-web runtimes. If this filter returns true, maintenance mode will be |
| 279 | * active and the request will end. If false, the request will be allowed to |
| 280 | * continue processing even if maintenance mode should be active. |
| 281 | * |
| 282 | * @since 4.6.0 |
| 283 | * |
| 284 | * @param bool $enable_checks Whether to enable maintenance mode. Default true. |
| 285 | * @param int $upgrading The timestamp set in the .maintenance file. |
| 286 | */ |
| 287 | if ( ! apply_filters( 'enable_maintenance_mode', true, $upgrading ) ) { |
| 288 | return false; |
| 289 | } |
| 290 | |
| 291 | return true; |
| 292 | } |
| 293 | |