функция
since 5.5.0
rest_default_additional_properties_to_false()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
rest_default_additional_properties_to_false( array $schema ): array
Описание
Устанавливает «additionalProperties» в false по умолчанию для всех определений объектов в схеме.
Параметры
$schema
array
обязательный
Схема для изменения.
Возвращаемое значение
array
Исходный код
wp-includes/rest-api.php:3148
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['patternProperties'] ) ) {
foreach ( $schema['patternProperties'] as $key => $child_schema ) {
$schema['patternProperties'][ $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;
}
История изменений
| Версия | Описание |
|---|---|
| 5.6.0 | Support the "patternProperties" keyword. |
| 5.5.0 | Introduced. |

