I lightened up one of my plugins to the maximum (which does several things), but in this specific case it only has to deal with a simple "maintenance mode".
I was testing the plugin on a fresh Wordpress installation (5.9.3), but the function (TestMaintenance) is never called.
<?php
/*
* Plugin Name: Test
* Description: Test
* Version: 1.0
* Author:Test
* Author URI: Test
* License: GPL3
* Text Domain: my-utility-test
*/
if (!defined('ABSPATH')) {
die('Direct access not allowed!');
}
class MyCustomPlugin {
public static $instance;
private function __construct() {
add_action('get_header', [$this, 'TestMaintenance']);
register_activation_hook(__FILE__, [$this, 'activation']);
register_uninstall_hook(__FILE__, 'uninstall');
}
public static function getInstance() {
if (!self::$instance instanceof self) {
self::$instance = new self();
}
return self::$instance;
}
public function activation() {
return true;
}
public static function uninstall() {
$options_list = [];
foreach ($options_list as $option) delete_option($option);
return true;
}
public function TestMaintenance() {
wp_die("<h1>Maintenance</h1>", get_bloginfo('name'), ['response' => 200]);
}
}
MyCustomPlugin::getInstance();