<?php
// includes/api/status.php
if (!defined('ABSPATH')) exit;

require_once AFB_PLUGIN_DIR . 'includes/lib/status-store.php';

/** AJAX: afb_status */
function afb_api_status() {
    $request_id = sanitize_text_field($_GET['request_id'] ?? $_POST['request_id'] ?? '');
    if (!$request_id) wp_send_json_error(['message'=>'Missing request_id']);
    wp_send_json_success(afb_status_get($request_id));
}
add_action('wp_ajax_afb_status',        'afb_api_status');
add_action('wp_ajax_nopriv_afb_status', 'afb_api_status');
