Sends a JSON response back to an Ajax request, indicating failure.
Description
If the $value parameter is a WP_Error object, the errors within the object are processed and output as an array of error codes and corresponding messages. All other types are output without further processing.
Parameters
$valuemixedoptional
Data to encode as JSON, then print and die. Default null.Default: null
$status_codeintoptional
The HTTP status code to output. Default null.Default: null
$flagsintoptional
Options to be passed to json_encode(). Default 0.Default: 0
Uses · 2
is_wp_error()Checks whether the given variable is a WordPress Error.
wp_send_json()Sends a JSON response back to an Ajax request.
Custom_Image_Header::ajax_header_crop()Gets attachment uploaded by Media Manager, crops it, then saves it as a new object. Returns JSON-encoded object details.
Signature, return type and hooks compared across 5 parsed releases.
7.1.0
Return type changed from none to never.verified against source
5.6.0
The $flags parameter was added.from the docblock
4.7.0
The $status_code parameter was added.from the docblock
4.1.0
The $value parameter is now processed if a WP_Error object is passed in.from the docblock
3.5.0
Introduced.from the docblock
About this page
Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.