filter_block_content

Advertisement

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

$text

(Required) Text that may contain block content.

$allowed_html

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

Default value: 'post'

$allowed_protocols

(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;
}

Advertisement

Changelog Changelog

Changelog
Version Description
5.3.1 Introduced.

Advertisement

Leave a Reply