Purpose

Fallback offer of the render-plan Compiler when its security-token gate refuses to cache raw expanded HTML (because it carries nonces or tokens). A registered handler may return marker-substituted HTML in which every nonce/token has been replaced with a __WR_NONCE_<unique>__ / __WR_TOKEN_<unique>__ placeholder. If the substituted HTML then passes the token gate, it is cached together with the marker list, and the HotRenderer re-injects fresh nonces at render time.

Usage

apply_filters(
    'wr_render_plan_nonce_aware_form_cache',
    null,                  // default → no support, fall back to the runtime bridge
    string $expandedHtml,  // do_shortcode output (carries nonce/token)
    string $rawHtml        // original object HTML with the shortcode still in it
);

The handler must inspect $rawHtml to decide whether it owns the shortcode in question, and return either null (refuse) or an array:

array{
    html: string,                 // marker-substituted HTML
    nonce_markers: array<int, array{placeholder:string, kind:string, action:string}>,
}

Security note

Only use this for output whose only per-user content is nonces/tokens. If the expanded HTML can contain per-user field values (prefill data, user-specific defaults), marker substitution would carry one user’s values into a shared cache. WR’s own [wr_form] deliberately does not register this filter for exactly that reason — forms always render through the runtime bridge.