WP_REST_Blocks_Controller::filter_response_by_context( array $data, string $context )

Filters a response based on the context defined in the schema.


Description Description


Parameters Parameters

$data

(array) (Required) Response data to fiter.

$context

(string) (Required) Context defined in the schema.


Top ↑

Return Return

(array) Filtered response.


Top ↑

Source Source

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

	public function filter_response_by_context( $data, $context ) {
		$data = parent::filter_response_by_context( $data, $context );

		/*
		 * Remove `title.rendered` and `content.rendered` from the response. It
		 * doesn't make sense for a reusable block to have rendered content on its
		 * own, since rendering a block requires it to be inside a post or a page.
		 */
		unset( $data['title']['rendered'] );
		unset( $data['content']['rendered'] );

		return $data;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.