['POST','GET'], 'callback' => [__CLASS__, 'handle'], 'permission_callback' => '__return_true', ]); }); } public static function handle(WP_REST_Request $req) { $intent_json = $req->get_body(); $sig = $req->get_header('x-mmi-signature'); $ts = (int)$req->get_header('x-mmi-timestamp'); if (!$intent_json || !$sig || !$ts) { return new WP_REST_Response([ 'ok'=>false, 'error'=>'missing_auth' ], 400); } if (!MMI_RemoteAuth::verify($intent_json, $ts, $sig)) { return new WP_REST_Response([ 'ok'=>false, 'error'=>'invalid_signature' ], 403); } $data = json_decode($intent_json, true); if (!is_array($data) || empty($data['id'])) { return new WP_REST_Response([ 'ok'=>false, 'error'=>'bad_intent' ], 400); } require_once IF_PLUGIN_DIR . 'includes/intents/index_0930.php'; $reg = if_build_intent_registry(); $ctx = [ 'dry_run' => false, 'safe_mode' => false, 'user_id' => 0, 'remote' => true, ]; $out = $reg->dispatch( (string)$data['id'], $data['payload'] ?? [], $data['meta'] ?? [], $ctx ); return new WP_REST_Response($out, 200); } }