Toggle maintenance mode for the site.
Creates/deletes the maintenance file to enable/disable maintenance mode.
(bool) (Optional) True to enable maintenance mode, false to disable.
Default value: false
File: wp-admin/includes/class-wp-upgrader.php
public function maintenance_mode( $enable = false ) { global $wp_filesystem; $file = $wp_filesystem->abspath() . '.maintenance'; if ( $enable ) { $this->skin->feedback( 'maintenance_start' ); // Create maintenance file to signal that we are upgrading. $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; $wp_filesystem->delete( $file ); $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE ); } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) { $this->skin->feedback( 'maintenance_end' ); $wp_filesystem->delete( $file ); } }
Version | Description |
---|---|
2.8.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_upgrader/maintenance_mode