--- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php Fri Sep 05 18:40:08 2025 +0200
@@ -54,7 +54,6 @@
'schema' => array( $this, 'get_public_item_schema' ),
)
);
-
}
/**
@@ -238,6 +237,7 @@
$default_schema = array(
'type' => empty( $args['type'] ) ? null : $args['type'],
+ 'title' => empty( $args['label'] ) ? '' : $args['label'],
'description' => empty( $args['description'] ) ? '' : $args['description'],
'default' => isset( $args['default'] ) ? $args['default'] : null,
);
@@ -258,7 +258,7 @@
continue;
}
- $rest_args['schema'] = $this->set_additional_properties_to_false( $rest_args['schema'] );
+ $rest_args['schema'] = rest_default_additional_properties_to_false( $rest_args['schema'] );
$rest_options[ $rest_args['name'] ] = $rest_args;
}
@@ -322,31 +322,22 @@
}
/**
- * Recursively add additionalProperties = false to all objects in a schema.
+ * Recursively add additionalProperties = false to all objects in a schema
+ * if no additionalProperties setting is specified.
*
- * This is need to restrict properties of objects in settings values to only
+ * This is needed to restrict properties of objects in settings values to only
* registered items, as the REST API will allow additional properties by
* default.
*
* @since 4.9.0
+ * @deprecated 6.1.0 Use {@see rest_default_additional_properties_to_false()} instead.
*
* @param array $schema The schema array.
* @return array
*/
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 );
- }
+ _deprecated_function( __METHOD__, '6.1.0', 'rest_default_additional_properties_to_false()' );
- $schema['additionalProperties'] = false;
- break;
- case 'array':
- $schema['items'] = $this->set_additional_properties_to_false( $schema['items'] );
- break;
- }
-
- return $schema;
+ return rest_default_additional_properties_to_false( $schema );
}
}