WordPress at Your Fingertips
function is not described

WP_REST_Meta_Fields::prepare_value_for_response() protected WP 4.7.0

Prepares a meta value for a response.

This is required because some native types cannot be stored correctly in the database, such as booleans. We need to cast back to the relevant type before passing back to JSON.

{} It's a method of the class: WP_REST_Meta_Fields{}

No Hooks.


Mixed. Prepared value.


// protected - for code of main (parent) or child class
$result = $this->prepare_value_for_response( $value, $request, $args );
$value(mixed) (required)
Meta value to prepare.
$request(WP_REST_Request) (required)
Current request object.
$args(array) (required)
Options for the field.

Code of WP_REST_Meta_Fields::prepare_value_for_response() WP 5.8.3

protected function prepare_value_for_response( $value, $request, $args ) {
	if ( ! empty( $args['prepare_callback'] ) ) {
		$value = call_user_func( $args['prepare_callback'], $value, $request, $args );

	return $value;