rest_json_encode_options
Filter HookDescription
Filters the JSON encoding options used to send the REST API response.Hook Information
File Location |
wp-includes/rest-api/class-wp-rest-server.php
View on GitHub
|
Hook Type | Filter |
Line Number | 266 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$options
|
JSON encoding options {@see json_encode()}. |
WP_REST_Request
|
$request
|
Current request object. |
Usage Examples
Basic Usage
<?php
// Hook into rest_json_encode_options
add_filter('rest_json_encode_options', 'my_custom_filter', 10, 2);
function my_custom_filter($options, $request) {
// Your custom filtering logic here
return $options;
}
Source Code Context
wp-includes/rest-api/class-wp-rest-server.php:266
- How this hook is used in WordPress core
<?php
261 * @since 6.1.0
262 *
263 * @param int $options JSON encoding options {@see json_encode()}.
264 * @param WP_REST_Request $request Current request object.
265 */
266 return apply_filters( 'rest_json_encode_options', $options, $request );
267 }
268
269 /**
270 * Handles serving a REST API request.
271 *
PHP Documentation
<?php
/**
* Filters the JSON encoding options used to send the REST API response.
*
* @since 6.1.0
*
* @param int $options JSON encoding options {@see json_encode()}.
* @param WP_REST_Request $request Current request object.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/rest-api/class-wp-rest-server.php
Related Hooks
Related hooks will be displayed here in future updates.