WordPress.org

Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #42061


Ignore:
Timestamp:
12/03/2017 09:01:23 PM (3 years ago)
Author:
joehoyle
Comment:

See https://github.com/WP-API/WP-API/issues/926 for the previous story on this.

Though we want to discourage use of global state functions like these, there _is_ a REST_REQUEST constant for this purpose. As mentioned in that ticket, the idea of "the current request is a REST one" breaks down for things like _embed requests, and internal rest_do_request calls, therefore we don't want to encourage the use of "is the current request a REST one" as it's not always in that context.

@lots.0.logs perhaps you could define why you need such a function? wp_doing_ajax/cron() are inherently process-level functions, but the REST API callback methods are not intended to scoped to the whole "page load" request.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #42061

    • Property Keywords has-patch added
    • Property Status changed from new to closed
    • Property Resolution changed from to wontfix
    • Property Milestone changed from Awaiting Review to
  • Ticket #42061 – Description

    initial v2  
    1 This patch adds a new function: `wp_doing_rest()` and filter by the same name that work exactly like the current `wp_doing_ajax/cron()` functions but for Rest API requests.
     1This patch adds a new function: `wp_doing_rest()` and filter by the same name that work exactly like the current `wp_doing_ajax/cron()` functions but for Rest API requests.