WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_REST_Controller::get_fields_for_response() WP 4.9.6

Gets an array of fields to be included on the response.

Included fields are based on item schema and _fields= request argument.

Это метод класса: WP_REST_Controller

Хуков нет.

Возвращает

Массив. Fields to be included in the response.

Использование

$WP_REST_Controller = new WP_REST_Controller();
$var = $WP_REST_Controller->get_fields_for_response( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request.

Код WP REST Controller::get fields for response: wp-includes/rest-api/endpoints/class-wp-rest-controller.php WP 5.2.2

<?php
public function get_fields_for_response( $request ) {
	$schema = $this->get_item_schema();
	$fields = isset( $schema['properties'] ) ? array_keys( $schema['properties'] ) : array();

	$additional_fields = $this->get_additional_fields();
	foreach ( $additional_fields as $field_name => $field_options ) {
		// For back-compat, include any field with an empty schema
		// because it won't be present in $this->get_item_schema().
		if ( is_null( $field_options['schema'] ) ) {
			$fields[] = $field_name;
		}
	}

	if ( ! isset( $request['_fields'] ) ) {
		return $fields;
	}
	$requested_fields = wp_parse_list( $request['_fields'] );
	if ( 0 === count( $requested_fields ) ) {
		return $fields;
	}
	// Trim off outside whitespace from the comma delimited list.
	$requested_fields = array_map( 'trim', $requested_fields );
	// Always persist 'id', because it can be needed for add_additional_fields_to_object().
	if ( in_array( 'id', $fields, true ) ) {
		$requested_fields[] = 'id';
	}
	return array_intersect( $fields, $requested_fields );
}