WP_Ability::normalize_input
Normalizes the input for the ability, applying the default value from the input schema when needed.
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.
Method of the class: WP_Ability{}
No Hooks.
Returns
Mixed. The same input, or the default from schema, or null if default not set.
Usage
$WP_Ability = new WP_Ability(); $WP_Ability->normalize_input( $input );
- $input(mixed)
- The raw input provided for the ability.
Default:null
Changelog
| Since 6.9.0 | Introduced. |
WP_Ability::normalize_input() WP Ability::normalize input code WP 6.9
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;
}