WP_REST_Settings_Controller::sanitize_callback( mixed $value, WP_REST_Request $request, string $param ): mixed|WP_Error

Custom sanitize callback used for all options to allow the use of ‘null’.

Description

By default, the schema of settings will throw an error if a value is set to null as it’s not a valid value for something like "type => string". We provide a wrapper sanitizer to allow the use of null.

Parameters

$valuemixedrequired
The value for the setting.
$requestWP_REST_Requestrequired
The request object.
$paramstringrequired
The parameter name.

Return

mixed|WP_Error

Source

public function sanitize_callback( $value, $request, $param ) {
	if ( is_null( $value ) ) {
		return $value;
	}

	return rest_parse_request_arg( $value, $request, $param );
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.