WP_REST_Controller::get_context_param

Advertisement

Summery Summery

Retrieves the magical context param.

Syntax Syntax

WP_REST_Controller::get_context_param( array $args = array() )

Description Description

Ensures consistent descriptions between endpoints, and populates enum from schema.

Parameters Parameters

$args

(Optional) Additional arguments for context parameter.

Default value: array()

Return Return

(array) Context parameter details.

Source Source

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

		}

		return array_merge( $param_details, $args );
	}

	/**
	 * Adds the values from additional fields to a data object.
	 *
	 * @since 4.7.0
	 *
	 * @param array           $prepared Prepared response array.
	 * @param WP_REST_Request $request  Full details about the request.
	 * @return array Modified data object with additional fields.
	 */
	protected function add_additional_fields_to_object( $prepared, $request ) {

		$additional_fields = $this->get_additional_fields();

		$requested_fields = $this->get_fields_for_response( $request );

		foreach ( $additional_fields as $field_name => $field_options ) {
			if ( ! $field_options['get_callback'] ) {
				continue;
			}

			if ( ! rest_is_field_included( $field_name, $requested_fields ) ) {
				continue;
			}

Advertisement

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Advertisement

Leave a Reply