-
Notifications
You must be signed in to change notification settings - Fork 195
Open
Description
Describe the bug
If another plugin uses the filter rest_pre_dispatch to make the REST API to return a custom response, ACF prevents it.
To Reproduce
- This code should stop any REST request:
add_filter(
'rest_pre_dispatch',
static function ( $response ) {
return new WP_Error( 'oh_no', __( 'Oh no no no no no.' ), array( 'status' => 404 ) );
},
5 // Lower than 10.
);- But with ACF enabled, it doesn't happen.
Code
class ACF_Rest_Api {
// ...
public function __construct() {
add_filter( 'rest_pre_dispatch', array( $this, 'initialize' ), 10, 3 );
add_action( 'rest_api_init', array( $this, 'register_field' ) );
}
public function initialize( $response, $handler, $request ) {
if ( ! acf_get_setting( 'rest_api_enabled' ) ) {
return; // Should return `$response`.
}
// ...
if ( acf_get_setting( 'rest_api_embed_links' ) ) {
$this->embed_links = new ACF_Rest_Embed_Links();
$this->embed_links->initialize();
}
// Should return `$response`.
}
// ...
}Version Information:
- WordPress Version 6.9-beta3
- PHP Version 8.0.29
- ACF Version 6.6.2
- "Browser" Insomnia 12
Metadata
Metadata
Assignees
Labels
No labels