Description
This is needed to restrict properties of objects in meta values to only registered items, as the REST API will allow additional properties by default.
Parameters
- $schema
-
(array) (Required) The schema array.
Source
File: wp-includes/rest-api/fields/class-wp-rest-meta-fields.php
protected function default_additional_properties_to_false( $schema ) {
switch ( $schema['type'] ) {
case 'object':
foreach ( $schema['properties'] as $key => $child_schema ) {
$schema['properties'][ $key ] = $this->default_additional_properties_to_false( $child_schema );
}
if ( ! isset( $schema['additionalProperties'] ) ) {
$schema['additionalProperties'] = false;
}
break;
case 'array':
$schema['items'] = $this->default_additional_properties_to_false( $schema['items'] );
break;
}
return $schema;
}
Changelog
Version | Description |
5.3.0 | Introduced. |