filter_block_kses_value( string[]|string $value, array[]|string $allowed_html, string[] $allowed_protocols = array(), array $block_context = null ): string[]|string

In this article

Filters and sanitizes a parsed block attribute value to remove non-allowable HTML.

Parameters

$valuestring[]|stringrequired
The attribute value to filter.
$allowed_htmlarray[]|stringrequired
An array of allowed HTML elements and attributes, or a context name such as 'post'. See wp_kses_allowed_html() for the list of accepted context names.
$allowed_protocolsstring[]optional
Array of allowed URL protocols.
Defaults to the result of wp_allowed_protocols() .

Default:array()

$block_contextarrayoptional
The block the attribute belongs to, in parsed block array format.

Default:null

Return

string[]|string The filtered and sanitized result.

Source

* If either callback returns a string value, it will be prepended and appended to the serialized
* block markup, respectively.
*
* The callbacks will receive a reference to the current block as their first argument, so that they
* can also modify it, and the current block's parent block as second argument. Finally, the
* `$pre_callback` receives the previous block, whereas the `$post_callback` receives
* the next block as third argument.
*
* Serialized blocks are returned including comment delimiters, and with all attributes serialized.
*
* This function should be used when there is a need to modify the saved blocks, or to inject markup
* into the return value. Prefer `serialize_blocks` when preparing blocks to be saved to post content.
*
* This function is meant for internal use only.
*
* @since 6.4.0
* @access private
*
* @see serialize_blocks()
*
* @param array[]  $blocks        An array of parsed blocks. See WP_Block_Parser_Block.

Changelog

VersionDescription
6.5.5Added the $block_context parameter.
5.3.1Introduced.

User Contributed Notes

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