Maintenance mode from functions.php is no longer available?

I am working on a site on WordPress and doing it for the first time since branch 3.x so I feel a little confused.

I’m using version 6.1 with default theme 2022, from which I made myself a child theme. Can someone take a look at my functions.php file and tell me why instead of a maintenance announcement, the site is throwing me a critical error?

<?php
function add_style() {
wp_enqueue_style( ‘style’, get_stylesheet_uri() );
}
add_action( ‘wp_enqueue_scripts’, ‘add_style’ );

function maintenance_mode() {
if ( !current_user_can( ‘edit_themes’ ) || !is_user_logged_in() ) {wp_die(‘Maintenance in progress. Please come back later.’);    
}
}

add_action(‘get_header’, ‘maintenance_mode’);

&#x200B;

1 Comment

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer