-
Notifications
You must be signed in to change notification settings - Fork 1
atmosphere_pre_apply_writes
github-actions[bot] edited this page Jul 14, 2026
·
5 revisions
Short-circuits the applyWrites call before it reaches the PDS.
Return a non-null array (success shape: [ 'results' => [...] ],
with one array result per write) or a WP_Error to bypass the
real HTTP round-trip. Used by
the PHPUnit suite, the FOSSE end-to-end harness, and anything
else that needs to observe or mock a write batch without
actually hitting the PDS.
A common use is pre_http_request, but that filter fires
inside wp_safe_remote_request, which is only reached after
the DPoP proof has been built — so in test environments
without a real DPoP JWK, the call errors out first. This
filter runs before any of that.
/**
* Short-circuits the applyWrites call before it reaches the PDS.
*
* Return a non-null array (success shape: `[ 'results' => [...] ]`,
* with one array result per write) or a `WP_Error` to bypass the
* real HTTP round-trip. Used by
* the PHPUnit suite, the FOSSE end-to-end harness, and anything
* else that needs to observe or mock a write batch without
* actually hitting the PDS.
*
* A common use is `pre_http_request`, but that filter fires
* inside `wp_safe_remote_request`, which is only reached after
* the DPoP proof has been built — so in test environments
* without a real DPoP JWK, the call errors out first. This
* filter runs before any of that.
*
* @param null|array|\WP_Error $short_circuit
* @param array $writes
* @return null|array|\WP_Error The filtered value.
*/
function my_atmosphere_pre_apply_writes_callback( null|array|\WP_Error $short_circuit, array $writes ) {
// Your code here.
return $short_circuit;
}
add_filter( 'atmosphere_pre_apply_writes', 'my_atmosphere_pre_apply_writes_callback', 10, 2 );-
null|array|\WP_Error$short_circuitShort-circuit value. Return null to skip. -
array$writesThe write batch about to be sent.
\apply_filters( 'atmosphere_pre_apply_writes', null, $writes )