Filters and sanitizes a parsed block attribute value to remove non-allowable HTML.
Parameters
$value
string[]|stringrequired- The attribute value to filter.
$allowed_html
array[]|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_protocols
string[]optional- Array of allowed URL protocols.
Defaults to the result of wp_allowed_protocols() .Default:
array()
$block_context
arrayoptional- The block the attribute belongs to, in parsed block array format.
Default:
null
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.
User Contributed Notes
You must log in before being able to contribute a note or feedback.