Uses
| Uses | Description |
|---|---|
| wp-includes/rest-api.php: rest_default_additional_properties_to_false() | Sets the “additionalProperties” to false by default for all object definitions in the schema. |
Sets the “additionalProperties” to false by default for all object definitions in the schema.
(array) (Required) The schema to modify.
(array) The modified schema.
File: wp-includes/rest-api.php
function rest_default_additional_properties_to_false( $schema ) {
$type = (array) $schema['type'];
if ( in_array( 'object', $type, true ) ) {
if ( isset( $schema['properties'] ) ) {
foreach ( $schema['properties'] as $key => $child_schema ) {
$schema['properties'][ $key ] = rest_default_additional_properties_to_false( $child_schema );
}
}
if ( ! isset( $schema['additionalProperties'] ) ) {
$schema['additionalProperties'] = false;
}
}
if ( in_array( 'array', $type, true ) ) {
if ( isset( $schema['items'] ) ) {
$schema['items'] = rest_default_additional_properties_to_false( $schema['items'] );
}
}
return $schema;
} | Version | Description |
|---|---|
| 5.5.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_default_additional_properties_to_false