WordPress at a glance
функция не описана

WP_REST_Settings_Controller::set_additional_properties_to_false() protected WP 4.9.0

Recursively add additionalProperties = false to all objects in a schema.

This is need to restrict properties of objects in settings values to only registered items, as the REST API will allow additional properties by default.

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

Хуков нет.

Возвращает

Array.

Использование

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

Changelog

Since 4.9.0 Introduced.

Код WP_REST_Settings_Controller::set_additional_properties_to_false() WP 5.5.1

<?php
protected function set_additional_properties_to_false( $schema ) {
	switch ( $schema['type'] ) {
		case 'object':
			foreach ( $schema['properties'] as $key => $child_schema ) {
				$schema['properties'][ $key ] = $this->set_additional_properties_to_false( $child_schema );
			}

			$schema['additionalProperties'] = false;
			break;
		case 'array':
			$schema['items'] = $this->set_additional_properties_to_false( $schema['items'] );
			break;
	}

	return $schema;
}