<?php
/**
 * Plugin Name: Brightery Secure 2FA
 * Description: Production-focused two-factor authentication for WordPress with TOTP, Passkeys/WebAuthn, role-based enforcement, REST/API policy controls, service-account allowlists, login-context alerts, WooCommerce integration, logs, and forced enrollment.
 * Version: 1.0.0
 * Author: Brightery
 * Author URI: https://www.brightery.com/
 * License: GPL v2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Requires at least: 6.2
 * Requires PHP: 7.4
 * Text Domain: brightery-secure-2fa
 */

if (!defined('ABSPATH')) {
    exit;
}

if (!defined('BS2FA_VERSION')) {
    define('BS2FA_VERSION', '10.0.0');
}

if (!defined('BS2FA_PATH')) {
    define('BS2FA_PATH', plugin_dir_path(__FILE__));
}

if (!defined('BS2FA_URL')) {
    define('BS2FA_URL', plugin_dir_url(__FILE__));
}

require_once BS2FA_PATH . 'includes/class-bs2fa-helpers.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-logger.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-rate-limit.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-trusted-devices.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-crypto.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-totp.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-cbor.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-webauthn.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-privacy.php';
require_once BS2FA_PATH . 'includes/class-bs2fa-plugin.php';

function bs2fa_plugin() {
    static $instance = null;

    if (null === $instance) {
        $instance = new BS2FA_Plugin();
    }

    return $instance;
}

register_activation_hook(__FILE__, ['BS2FA_Plugin', 'activate']);
register_deactivation_hook(__FILE__, ['BS2FA_Plugin', 'deactivate']);

add_action('plugins_loaded', function () {
    bs2fa_plugin()->init();
});
