[wp-trac] [WordPress Trac] #28523: wp_send_json to allow for JSONP
WordPress Trac
noreply at wordpress.org
Fri Jun 13 00:15:40 UTC 2014
#28523: wp_send_json to allow for JSONP
-------------------------+------------------------------
Reporter: sc0ttkclark | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.5
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------------------
Comment (by sc0ttkclark):
If the custom endpoint is coded for that, and origin policies have been
overridden, that could happen -- see allowed_http_origins and
allowed_http_origin filters.
I don't suspect that'll be much of a problem since lamen won't be using
JSONP and callbacks, right?
Also my code in the initial description can be improved further:
{{{
$content_type = 'application/json';
$json_response = json_encode( $response );
// JSONP callback support
if ( null !== $callback ) {
// JSONP requires content type of application/javascript
$content_type = 'application/javascript';
// JSONP uses callback for response
$json_response = esc_js( $callback ) . '(' . json_response . ')';
}
@header( 'Content-Type: ' . $content_type . '; charset=' . get_option(
'blog_charset' ) );
echo $json_response;
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28523#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list