WP_REST_Abilities_V1_Run_Controller::sanitize_input_for_ability( mixed $input, WP_REST_Request $request ): mixed

Sanitizes the run input by coercing it to the ability’s input schema.

Description

Registered as the input argument sanitize_callback so that both check_ability_permissions() and execute_ability() receive natively typed input regardless of transport.

See also

Parameters

$inputmixedrequired
Raw input extracted from the request.
$requestWP_REST_Requestrequired
The request object.

Return

mixed Coerced input, or the raw input when it cannot be safely coerced.

Source

public function sanitize_input_for_ability( $input, $request ) {
	$ability = wp_has_ability( $request['name'] ) ? wp_get_ability( $request['name'] ) : null;
	if ( ! $ability instanceof WP_Ability ) {
		return $input;
	}

	return $this->coerce_input_to_schema( $input, $ability );
}

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

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