filter_block_content() – Filters and sanitizes block content to remove non-allowable HTML from parsed block attribute values.

You appear to be a bot. Output may be restricted

Description

Filters and sanitizes block content to remove non-allowable HTML from parsed block attribute values.

Usage

$string = filter_block_content( $text, $allowed_html, $allowed_protocols );

Parameters

$text
( string ) required – Text that may contain block content.
$allowed_html
( array[]|string ) optional default: post – An array of allowed HTML elements and attributes, or a context name such as 'post'.
$allowed_protocols
( string[] ) optional – Array of allowed URL protocols.

Returns

string The filtered and sanitized content result.

Source

File name: wordpress/wp-includes/blocks.php
Lines:

1 to 11 of 11
function filter_block_content( $text, $allowed_html = 'post', $allowed_protocols = array() ) {
  $result = '';

  $blocks = parse_blocks( $text );
  foreach ( $blocks as $block ) {
    $block   = filter_block_kses( $block, $allowed_html, $allowed_protocols );
    $result .= serialize_block( $block );
  }

  return $result;
}
 

 View on GitHub View on Trac