[wp-trac] [WordPress Trac] #35666: Add support for HTTP response codes to wp_send_json_error(), wp_send_json_success(), and wp_send_json

WordPress Trac noreply at wordpress.org
Mon Oct 24 13:24:32 UTC 2016


#35666: Add support for HTTP response codes to wp_send_json_error(),
wp_send_json_success(), and wp_send_json
-------------------------------------+--------------------------
 Reporter:  johnbillion              |       Owner:  stevenkword
     Type:  enhancement              |      Status:  reviewing
 Priority:  normal                   |   Milestone:  4.7
Component:  Formatting               |     Version:  3.5
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+--------------------------

Comment (by johnbillion):

 [attachment:35666.2.diff] tackles this by always telling `wp_die()` not to
 set an HTTP status code header.

 With output buffering on, this means a status set by `wp_send_json()`
 doesn't get clobbered. With output buffering off, the functionality
 doesn't change because `headers_sent()` in `_ajax_wp_die_handler()` is
 always true (due to the JSON echoed in `wp_send_json()`) so the status
 header doesn't get set anyway.

 @westonruter Wanna give this a whirl?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35666#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list