register_routes(); (new BL_Earnings_Controller())->register_routes(); }); /** * CORS for the assessment frontend on :3000. * * Kept deliberately simple. Task 4 does not concern this file. */ add_action('init', function () { $origin = $_SERVER['HTTP_ORIGIN'] ?? ''; if (preg_match('#^http://localhost:\d+$#', $origin)) { header('Access-Control-Allow-Origin: ' . $origin); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); header('Access-Control-Allow-Headers: Content-Type, Authorization, Idempotency-Key'); } if (($_SERVER['REQUEST_METHOD'] ?? '') === 'OPTIONS') { status_header(200); exit; } }); /** * WP-CLI helper so the environment can be reset between attempts. * * wp bemalearn reset */ if (defined('WP_CLI') && WP_CLI) { WP_CLI::add_command('bemalearn reset', function () { BL_Migrations::run(); BL_Seeder::seed(true); WP_CLI::success('Bema Learn data reset.'); }); }