wp_pre_kses_block_attributes( string $content, array[]|string $allowed_html, string[] $allowed_protocols ): string

In this article

Removes non-allowable HTML from parsed block attribute values when filtering in the post context.

Parameters

$contentstringrequired
Content to be run through KSES.
$allowed_htmlarray[]|stringrequired
An array of allowed HTML elements and attributes, or a context name such as 'post'.
$allowed_protocolsstring[]required
Array of allowed URL protocols.

Return

string Filtered text to run through KSES.

Source

function wp_pre_kses_block_attributes( $content, $allowed_html, $allowed_protocols ) {
	/*
	 * `filter_block_content` is expected to call `wp_kses`. Temporarily remove
	 * the filter to avoid recursion.
	 */
	remove_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10 );
	$content = filter_block_content( $content, $allowed_html, $allowed_protocols );
	add_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10, 3 );

	return $content;
}

Changelog

VersionDescription
5.3.1Introduced.

User Contributed Notes

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