WP_Ability::normalize_input( mixed $input = null ): mixed

Normalizes the input for the ability, applying the default value from the input schema when needed.

Description

When no input is provided and the input schema is defined with a top-level default key, this method returns the value of that key. If the input schema does not define a default, or if the input schema is empty, this method returns null. If input is provided, it is returned as-is.

Parameters

$inputmixedoptional
The raw input provided for the ability.

Default:null

Return

mixed The same input, or the default from schema, or null if default not set.

Source

public function normalize_input( $input = null ) {
	if ( null !== $input ) {
		return $input;
	}

	$input_schema = $this->get_input_schema();
	if ( ! empty( $input_schema ) && array_key_exists( 'default', $input_schema ) ) {
		return $input_schema['default'];
	}

	return null;
}

Changelog

VersionDescription
6.9.0Introduced.

User Contributed Notes

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