Tribe__Tickets__Editor::update_blocks( $post_id )
Update tickets blocks when the action: tribe_tickets_update_blocks_from_classic_editor is fired. When this action is fired couple of actions happens:
Contents
- Remove all the inner blocks and replaces with just the name of the tickets block
- Replace the placeholder ticket block with all the tickets associated with the Event / POST as blocks
- Update the content of the post
Parameters
- $post_id
-
(Required)
Return
(bool)
Source
File: src/Tribe/Editor.php
public function update_blocks( $post_id ) {
$post = get_post( $post_id );
if ( ! ( $post instanceof WP_Post ) ) {
return false;
}
/** @var Tribe__Editor__Utils $editor_utils */
$editor_utils = tribe( 'editor.utils' );
$block_name = $editor_utils->to_tribe_block_name( 'tickets' );
// Replace all the inner blocks with a general block name with no tickets inside.
$editor_utils->remove_inner_blocks( $post_id, $block_name, "<!-- $block_name /-->" );
$content = get_post_field( 'post_content', $post_id );
$post_content = $this->update_tickets_block_with_childs( $content, $post, array() );
return wp_update_post( array(
'ID' => $post->ID,
'post_content' => $post_content,
) );
}
Changelog
| Version | Description |
|---|---|
| 4.9.2 | Introduced. |