WP_Upgrader::maintenance_mode() WordPress Method
The WP_Upgrader::maintenance_mode() method puts the website into maintenance mode by creating a file called .maintenance in the website's root directory. This file contains the message that will be displayed to visitors while the website is in maintenance mode.
WP_Upgrader::maintenance_mode( bool $enable = false ) #
Toggle maintenance mode for the site.
Description
Creates/deletes the maintenance file to enable/disable maintenance mode.
Parameters
- $enable
(bool)(Optional)True to enable maintenance mode, false to disable.
Default value: false
Source
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 ); } }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |