Blocks::tribe_blocks_editor_update_classic_content( string $content, WP_Post $post, array $blocks )
Removes specified blocks from the provided content.
Contents
This method is designed to strip out blocks that aren’t needed from the post content.
Parameters
- $content
-
(string) (Required) The original content from which blocks will be removed.
- $post
-
(WP_Post) (Required) The post object related to the content being processed.
- $blocks
-
(array) (Required) An array of block structures related to the content.
Return
(string) The content with specified blocks removed.
Source
File: src/Events_Community/Block_Conversion/Blocks.php
public function tribe_blocks_editor_update_classic_content( $content, $post, $blocks ) {
if ( ! $this->is_community_event_post( $post ) ) {
return;
}
// Patterns to match the sections to be removed
// Includes: tribe/tickets, tribe/rsvp, and tribe/attendees.
$patterns = [
'/<!-- wp:tribe\/tickets -->.*?<!-- \/wp:tribe\/tickets -->/s',
'/<!-- wp:tribe\/rsvp\s+\/-->/s',
'/<!-- wp:tribe\/attendees\s+\/-->/s',
];
foreach ( $patterns as $pattern ) {
$content = preg_replace( $pattern, '', $content );
}
return $content;
}
Changelog
| Version | Description |
|---|---|
| 4.10.17 | Introduced. |