filter_block_content()
Filters and sanitizes block content to remove non-allowable HTML from parsed block attribute values.
Хуков нет.
Возвращает
Строку
. The filtered and sanitized content result.
Использование
filter_block_content( $text, $allowed_html, $allowed_protocols );
- $text(строка) (обязательный)
- Text that may contain block content.
- $allowed_html(array[]|строка)
- 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.
По умолчанию: 'post' - $allowed_protocols(string[])
- Array of allowed URL protocols.
По умолчанию: result of wp_allowed_protocols()
Список изменений
С версии 5.3.1 | Введена. |
Код filter_block_content() filter block content WP 6.2.2
function filter_block_content( $text, $allowed_html = 'post', $allowed_protocols = array() ) { $result = ''; if ( false !== strpos( $text, '<!--' ) && false !== strpos( $text, '--->' ) ) { $text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text ); } $blocks = parse_blocks( $text ); foreach ( $blocks as $block ) { $block = filter_block_kses( $block, $allowed_html, $allowed_protocols ); $result .= serialize_block( $block ); } return $result; }