WP_REST_Controller::add_additional_fields_schema

Advertisement

Summery Summery

Adds the schema from additional fields to a schema array.

Syntax Syntax

WP_REST_Controller::add_additional_fields_schema( array $schema )

Description Description

The type of object is inferred from the passed schema.

Parameters Parameters

$schema

(Required) Schema array.

Return Return

(array) Modified Schema array.

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-controller.php

	 *
	 * @param string $object_type Optional. The object type.
	 * @return array Registered additional fields (if any), empty array if none or if the object type could
	 *               not be inferred.
	 */
	protected function get_additional_fields( $object_type = null ) {

		if ( ! $object_type ) {
			$object_type = $this->get_object_type();
		}

		if ( ! $object_type ) {
			return array();
		}

		global $wp_rest_additional_fields;

		if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) {
			return array();
		}

Advertisement

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Advertisement

Leave a Reply