On this page
wp_pre_kses_block_attributes( string $string, array[]|string $allowed_html, string[] $allowed_protocols ): string
Removes non-allowable HTML from parsed block attribute values when filtering in the post context.
Parameters
$stringstring Required-
Content to be run through KSES.
$allowed_htmlarray[]|string Required-
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
File: wp-includes/formatting.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| filter_block_content() wp-includes/blocks.php | Filters and sanitizes block content to remove non-allowable HTML from parsed block attribute values. |
| remove_filter() wp-includes/plugin.php | Removes a callback function from a filter hook. |
| add_filter() wp-includes/plugin.php | Adds a callback function to a filter hook. |
Changelog
| Version | Description |
|---|---|
| 5.3.1 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_pre_kses_block_attributes