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

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

Parameters Parameters


(string) (Required) Content to be run through KSES.


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


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

Top ↑

Return Return

(string) Filtered text to run through KSES.

Top ↑

Source Source

File: wp-includes/formatting.php

function wp_pre_kses_block_attributes( $string, $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 );
	$string = filter_block_content( $string, $allowed_html, $allowed_protocols );
	add_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10, 3 );

	return $string;

Top ↑

Changelog Changelog

Version Description
5.3.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

Top ↑

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