wp_pre_kses_block_attributes() WordPress Function

wp_pre_kses_block_attributes() is a function that takes an HTML attribute name and value, and returns a value that has been filtered by the kses system. This function is used to filter the attributes of a block element before they are added to the database.

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

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


Parameters

$string

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

$allowed_html

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

$allowed_protocols

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


Top ↑

Return

(string) Filtered text to run through KSES.


Top ↑

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
VersionDescription
5.3.1Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More