How do I check if the site is in maintenance mode?
From a procedural hook you'll probably need to use something like:

use Drupal\Core\Routing\RouteMatch;

...

$maintenance_mode = \Drupal::service('maintenance_mode');
$route_match = RouteMatch::createFromRequest(\Drupal::request());

if ($maintenance_mode-&gt;applies($route_match)) {
  // ...
}