Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mikkamp opened this issue Mar 8, 2024 · 0 comments
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.

Comments

@mikkamp
Copy link
Contributor

mikkamp commented Mar 8, 2024

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.

@mikkamp mikkamp added the type: enhancement The issue is a request for an enhancement. label Mar 8, 2024
@mikkamp mikkamp changed the title Use wp_is_rest_request to detect if we are handling a REST API request Use wp_is_serving_rest_request to detect if we are handling a REST API request Mar 8, 2024
@ianlin ianlin added the priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants