Blocks::extract_block_text( string $text )
Takes the content with block editor markup and tries to filter out the main content to display on the submit event page.
Contents
Parameters
- $text
-
(string) (Required) The text with block editor formatting.
Return
(string) The content without block editor markup.
Source
File: src/Events_Community/Block_Conversion/Blocks.php
public function extract_block_text( string $text ): string {
$blocks = parse_blocks( $text );
$textarea_content = '';
foreach ( $blocks as $block ) {
if ( isset( $block['innerHTML'] ) ) {
$textarea_content .= $block['innerHTML'] . "\n"; // Adding a newline for separation.
}
}
$return_text = $this->remove_wp_block_classes_and_clean( $textarea_content );
$visual_editor = tribe( 'community.main' )->useVisualEditor;
if ( ! $visual_editor ) {
// Only add wpautop if the textarea is enabled.
$return_text = wpautop( $return_text );
}
$return_text = trim( $return_text );
return $return_text;
}
Changelog
| Version | Description |
|---|---|
| 4.10.17 | Introduced. |