#51293 closed feature request (fixed)
Add $option Parameter to wp_send_json, wp_send_json_success and wp_send_json_error
Reported by: | eroraghav | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | 5.5.1 |
Component: | General | Keywords: | has-patch commit has-dev-note |
Focuses: | Cc: |
Description
I mostly use wp_send_json function(s) as they work perfectly with wp.ajax.post and wp.ajax.send functions. But there was one problem that i was not able to use JSON Constants (FLAGS ) https://www.php.net/manual/en/json.constants.php
So i made an edit to add this option parameter that will be used to add JSON Constant.
$option is Optional. Options to be passed to json_encode(). Default 0.
Attachments (2)
Change History (12)
This ticket was mentioned in PR #528 on WordPress/wordpress-develop by Ero-Raghav.
4 years ago
#1
- Keywords has-patch added; needs-refresh removed
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
4 years ago
#3
@
4 years ago
- Focuses accessibility removed
Removing the accessibility
focus as this issue doesn't seem related to web content accessibility.
#4
@
4 years ago
- Keywords 2nd-opinion removed
- Milestone changed from Awaiting Review to 5.6
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
Hi there, welcome to WordPress Trac! Thanks for the ticket and the PR.
Since wp_json_encode()
already has the $options
parameter, I agree that being able to utilize it in these functions seems like a useful addition.
@
4 years ago
Refreshed the patch against trunk. Also, changed the $option
parameter in the PR to $options
to maintain consistency with wp_json_encode
.
#5
@
4 years ago
- Keywords commit added
Thanks for the ticket & patch @eroraghav, and refresh @hareesh-pillai. Testing it looks good to me, applies clean and all existing tests run nicely. I did make one minor change in 51293.2.diff to fix the CS issue with the @param descriptions as they should all aligned off of the longest param.
@SergeyBiryukov would you care to give it a review/test, I wasn't sure if the change warranted unit tests?
#7
@
4 years ago
- Keywords needs-dev-note added
Marking for a small call-out on the Misc Dev Note for the new parameter added in 5.6.
hellofromtonya commented on PR #528:
4 years ago
#8
Merged in changeset https://core.trac.wordpress.org/changeset/49235
I mostly use wp_send_json function(s) as they work perfectly with wp.ajax.post and wp.ajax.send functions. But there was one problem that i was not able to use [JSON Constants (FLAGS )] (https://www.php.net/manual/en/json.constants.php).
So i made an edit to add this option parameter that will be used to add JSON Constant.
$option is Optional. Options to be passed to json_encode(). Default 0.
[Ticket] (https://core.trac.wordpress.org/ticket/51293)