Summery Summery

Prepares a value for output based off a schema array.

Syntax Syntax

WP_REST_Settings_Controller::prepare_value( mixed $value, array $schema )

Parameters Parameters


(mixed) (Required) Value to prepare.


(array) (Required) Schema to match.

Return Return

(mixed) The prepared value.

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php

	protected function prepare_value( $value, $schema ) {
		 * If the value is not valid by the schema, set the value to null.
		 * Null values are specifically non-destructive, so this will not cause
		 * overwriting the current invalid value to null.
		if ( is_wp_error( rest_validate_value_from_schema( $value, $schema ) ) ) {
			return null;

		return rest_sanitize_value_from_schema( $value, $schema );


Changelog Changelog

Version Description
4.7.0 Introduced.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.