WordPress at a glance
function is not described

WP_REST_Term_Search_Handler::prepare_item() public WP 5.6.0

Prepares the search result for a given ID.

{} It's a method of the class: WP_REST_Term_Search_Handler{}

No Hooks.

Return

Array. Associative array containing all fields for the item.

Usage

$WP_REST_Term_Search_Handler = new WP_REST_Term_Search_Handler();
$WP_REST_Term_Search_Handler->prepare_item( $id, $fields );
$id(int) (required)
Item ID.
$fields(array) (required)
Fields to include for the item.

Changelog

Since 5.6.0 Introduced.

Code of WP_REST_Term_Search_Handler::prepare_item() WP 5.6

<?php
public function prepare_item( $id, array $fields ) {
	$term = get_term( $id );

	$data = array();

	if ( in_array( WP_REST_Search_Controller::PROP_ID, $fields, true ) ) {
		$data[ WP_REST_Search_Controller::PROP_ID ] = (int) $id;
	}
	if ( in_array( WP_REST_Search_Controller::PROP_TITLE, $fields, true ) ) {
		$data[ WP_REST_Search_Controller::PROP_TITLE ] = $term->name;
	}
	if ( in_array( WP_REST_Search_Controller::PROP_URL, $fields, true ) ) {
		$data[ WP_REST_Search_Controller::PROP_URL ] = get_term_link( $id );
	}
	if ( in_array( WP_REST_Search_Controller::PROP_TYPE, $fields, true ) ) {
		$data[ WP_REST_Search_Controller::PROP_TYPE ] = $term->taxonomy;
	}

	return $data;
}