Warning: This method has been deprecated. Use rest_default_additional_properties_to_false() instead.

WP_REST_Meta_Fields::default_additional_properties_to_false() WordPress Method

The WP_REST_Meta_Fields::default_additional_properties_to_false() method is a utility function that sets the default value for the additional_properties field to false. This is useful when adding custom fields to the REST API, as it ensures that only the fields that are explicitly whitelisted will be exposed in the response.

WP_REST_Meta_Fields::default_additional_properties_to_false( array $schema ) #

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


Description

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.


Top ↑

Parameters

$schema

(array)(Required)The schema array.


Top ↑

Return

(array)


Top ↑

Source

File: wp-includes/rest-api/fields/class-wp-rest-meta-fields.php

	protected function default_additional_properties_to_false( $schema ) {
		_deprecated_function( __METHOD__, '5.6.0', 'rest_default_additional_properties_to_false()' );

		return rest_default_additional_properties_to_false( $schema );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.6.0Use rest_default_additional_properties_to_false() instead.
5.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.