WP_REST_Settings_Controller::sanitize_callback

Advertisement

Summery Summery

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

Syntax Syntax

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

Description 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 whitelist the use of null.

Parameters Parameters

$value

(Required) The value for the setting.

$request

(Required) The request object.

$param

(Required) The parameter name.

Return Return

(mixed|WP_Error)

Source Source

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

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

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

Advertisement

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Advertisement

Leave a Reply