Обновление:
function wp_maintenance_mode() {
// Extra, don't run if WordPress is doing updates
if ( file_exists( ABSPATH . '.maintenance' ) || wp_installing() ) {
return;
}
// Activate Maintenance Mode
if (!current_user_can('edit_themes') || !is_user_logged_in()) {
wp_die('<h1>Under Maintenance</h1><br />Something aint right, but were working on it! Check back later.');
}
}
add_action('get_header', 'wp_maintenance_mode');
// Disable the maintenance if your condition is met.
if( you_condition ) {
remove_action('get_header', 'wp_maintenance_mode');
}
Кроме того, вы можете проверить, есть ли какой-нибудь cron в процессе:
if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
// code to be run if there is a cron in progress
}