Use wp_is_serving_rest_request to detect if we are handling a REST API request #2303
Labels
priority: low
The issue/PR is low priority—not many people are affected or there’s a workaround, etc.
type: enhancement
The issue is a request for an enhancement.
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.The text was updated successfully, but these errors were encountered: