Skip to content

Use wp_is_serving_rest_request to detect if we are handling a REST API request #2303

@mikkamp

Description

@mikkamp

User story

In WordPress 6.5 a new helper function wp_is_serving_rest_request is introduced. For better reliability we should make use of this function.
See: https://core.trac.wordpress.org/changeset/57312

We have one location in the code where we use the old method defined( 'REST_REQUEST' ) && REST_REQUEST
Since we support WordPress L-2 we'll have to make it conditional and fallback to the old method if wp_is_serving_rest_request is not available. But we might as well start using the newer method as it might be more reliable since it's filterable. Edit: Final version is not filterable, so there are less benefits in using the helper function.

Metadata

Metadata

Labels

priority: normalThe issue/PR is normal priority—not many people are affected or there’s a workaround, etc.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions