Gets the encoding options passed to wp_json_encode.
$requestWP_REST_Requestrequired
protected function get_json_encode_options( WP_REST_Request $request ) {
$options = 0;
if ( $request->has_param( '_pretty' ) ) {
$options |= JSON_PRETTY_PRINT;
}
/**
* Filters the JSON encoding options used to send the REST API response.
*
* @since 6.1.0
*
* @param int $options JSON encoding options json_encode().
* @param WP_REST_Request $request Current request object.
*/
return apply_filters( 'rest_json_encode_options', $options, $request );
}
Filters the JSON encoding options used to send the REST API response.
| Version | Description |
|---|---|
| 6.1.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_server/get_json_encode_options