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

WP_REST_Templates_Controller::prepare_item_for_response() public WP 5.8.0

Prepare a single template output for response

{} Это метод класса: WP_REST_Templates_Controller{}

Хуков нет.

Возвращает

WP_REST_Response. $data

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

$WP_REST_Templates_Controller = new WP_REST_Templates_Controller();
$WP_REST_Templates_Controller->prepare_item_for_response( $template, $request ) // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable;
$template(WP_Block_Template) (обязательный)
Template instance.
$request(WP_REST_Request) (обязательный)
Request object.

Список изменений

С версии 5.8.0 Введена.

Код WP_REST_Templates_Controller::prepare_item_for_response() WP 5.8.1

public function prepare_item_for_response( $template, $request ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
	$result = array(
		'id'             => $template->id,
		'theme'          => $template->theme,
		'content'        => array( 'raw' => $template->content ),
		'slug'           => $template->slug,
		'source'         => $template->source,
		'type'           => $template->type,
		'description'    => $template->description,
		'title'          => array(
			'raw'      => $template->title,
			'rendered' => $template->title,
		),
		'status'         => $template->status,
		'wp_id'          => $template->wp_id,
		'has_theme_file' => $template->has_theme_file,
	);

	if ( 'wp_template_part' === $template->type ) {
		$result['area'] = $template->area;
	}

	$result = $this->add_additional_fields_to_object( $result, $request );

	$response = rest_ensure_response( $result );
	$links    = $this->prepare_links( $template->id );
	$response->add_links( $links );
	if ( ! empty( $links['self']['href'] ) ) {
		$actions = $this->get_available_actions();
		$self    = $links['self']['href'];
		foreach ( $actions as $rel ) {
			$response->add_link( $rel, $self );
		}
	}

	return $response;
}