WP_REST_Settings_Controller::sanitize_callback()publicWP 4.7.0

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

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.

Method of the class: WP_REST_Settings_Controller{}

No Hooks.

Return

Mixed|WP_Error.

Usage

$WP_REST_Settings_Controller = new WP_REST_Settings_Controller();
$WP_REST_Settings_Controller->sanitize_callback( $value, $request, $param );
$value(mixed) (required)
The value for the setting.
$request(WP_REST_Request) (required)
The request object.
$param(string) (required)
The parameter name.

Changelog

Since 4.7.0 Introduced.

WP_REST_Settings_Controller::sanitize_callback() code WP 6.4.3

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

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