<?php

namespace ARCHM\Admin;

// Exit if accessed directly.
defined('ABSPATH') || exit(1);

class Security {

    public function __construct() {
        add_action('send_headers', [ $this, 'add_security_headers' ]);
    }

    // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound
    public function add_security_headers(): void {
        if ( ! headers_sent() ) {
            header('X-Content-Type-Options: nosniff');
            header('X-Frame-Options: SAMEORIGIN');
            header('X-XSS-Protection: 1; mode=block');
            header('Referrer-Policy: strict-origin-when-cross-origin');
            header('Permissions-Policy: geolocation=(), microphone=()');
        }
    }
}
