Virtual_Event::render( array $attributes = array() )
Since we are dealing with a Dynamic type of Block we need a PHP method to render it.
Contents
Parameters
- $attributes
-
(array) (Optional)
Default value: array()
Return
(string)
Source
File: src/Tribe/Editor/Blocks/Virtual_Event.php
public function render( $attributes = [] ) {
if (
! tribe( 'editor' )->should_load_blocks()
|| ! tribe( 'events.editor.compatibility' )->is_blocks_editor_toggled_on()
) {
return '';
}
$args = [];
$args['attributes'] = $this->attributes( $attributes );
$args['post_id'] = $post_id = tribe( 'events.editor.template' )->get( 'post_id', null, false );
/* @var Tribe\Events\Virtual\Editor\Template\Frontend $frontend */
$frontend = tribe( Frontend::class );
// Add the rendering attributes into global context.
$frontend->add_template_globals( $args );
return $frontend->template( [ 'blocks', $this->slug() ], $args, false );
}
Changelog
| Version | Description |
|---|---|
| 1.7.1 | Introduced. |