Make WordPress Core

Opened 4 years ago

Last modified 9 months ago

#36271 new enhancement

Trigger _doing_it_wrong if wp_send_json is used on a REST API request

Reported by: rmccue Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: REST API Keywords: needs-patch has-unit-tests
Focuses: Cc:


We should heavily discourage users from using wp_send_json (& co.) on REST API requests. Two changes I want to make:

  1. If _doing_it_wrong is triggered on a REST request, we should add a header ala the _deprecated_function headers.
  2. If wp_send_json is called on a REST request, we should trigger a _doing_it_wrong and point people towards WP_REST_Response and WP_Error

Change History (1)

#1 @rachelbaker
4 years ago

  • Keywords has-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

Moved into Future Release, needs a patch.

Note: See TracTickets for help on using tickets.