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

WP_REST_Pattern_Directory_Controller::prepare_item_for_response() public WP 5.8.0

Prepare a raw pattern before it's output in an API response.

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

Хуки из метода
Возвращает

WP_REST_Response.

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

$WP_REST_Pattern_Directory_Controller = new WP_REST_Pattern_Directory_Controller();
$WP_REST_Pattern_Directory_Controller->prepare_item_for_response( $raw_pattern, $request );
$raw_pattern(объект) (обязательный)
A pattern from api.wordpress.org, before any changes.
$request(WP_REST_Request) (обязательный)
Request object.

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

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

Код WP_REST_Pattern_Directory_Controller::prepare_item_for_response() WP 5.8.1

public function prepare_item_for_response( $raw_pattern, $request ) {
	$prepared_pattern = array(
		'id'             => absint( $raw_pattern->id ),
		'title'          => sanitize_text_field( $raw_pattern->title->rendered ),
		'content'        => wp_kses_post( $raw_pattern->pattern_content ),
		'categories'     => array_map( 'sanitize_title', $raw_pattern->category_slugs ),
		'keywords'       => array_map( 'sanitize_title', $raw_pattern->keyword_slugs ),
		'description'    => sanitize_text_field( $raw_pattern->meta->wpop_description ),
		'viewport_width' => absint( $raw_pattern->meta->wpop_viewport_width ),
	);

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

	$response = new WP_REST_Response( $prepared_pattern );

	/**
	 * Filters the REST API response for a pattern.
	 *
	 * @since 5.8.0
	 *
	 * @param WP_REST_Response $response    The response object.
	 * @param object           $raw_pattern The unprepared pattern.
	 * @param WP_REST_Request  $request     The request object.
	 */
	return apply_filters( 'rest_prepare_block_pattern', $response, $raw_pattern, $request );
}