WordPress at a glance
function is not described

WP_REST_Meta_Fields::default_additional_properties_to_false() protected WP 5.3.0

Recursively add additionalProperties = false to all objects in a schema if no additionalProperties setting is specified.

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.

It's a method of the class: WP_REST_Meta_Fields{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->default_additional_properties_to_false( $schema );
$schema(array) (required)
The schema array.

Changelog

Since 5.3.0 Introduced.

Code of WP_REST_Meta_Fields::default_additional_properties_to_false() WP 5.5.1

<?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;
}