Summery Summery

Filters and sanitizes block content to remove non-allowable HTML from parsed block attribute values.

Syntax Syntax

filter_block_content( string $text, array[]|string $allowed_html = 'post', string[] $allowed_protocols = array() )

Parameters Parameters


(string) (Required) Text that may contain block content.


(array[]|string) (Optional) An array of allowed HTML elements and attributes, or a context name such as 'post'.

Default value: 'post'


(string[]) (Optional) Array of allowed URL protocols.

Default value: array()

Return Return

(string) The filtered and sanitized content result.

Source Source

File: wp-includes/blocks.php

function filter_block_content( $text, $allowed_html = 'post', $allowed_protocols = array() ) {
	$result = '';

	$blocks = parse_blocks( $text );
	foreach ( $blocks as $block ) {
		$block   = filter_block_kses( $block, $allowed_html, $allowed_protocols );
		$result .= serialize_block( $block );

	return $result;


Changelog Changelog

Version Description
5.3.1 Introduced.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.