[self::class, 'render'], 'editor_script' => 'ivyforms-gutenberg-block', 'editor_style' => 'ivyforms-gutenberg-block-editor', ]); return; } register_block_type('ivyforms/gutenberg-block', [ 'render_callback' => [self::class, 'render'], 'attributes' => BlockAttributes::getAttributes(), 'api_version' => '2', ]); } /** * Render the Gutenberg block * * @param array $attributes Block attributes * @return string Rendered block HTML * @throws ValidationException */ public static function render(array $attributes): string { $formId = GutenbergBlockRenderer::getFormIdFromAttributes($attributes); if ($formId === 0) { return GutenbergBlockRenderer::renderNoFormSelected(); } $form = GutenbergBlockRenderer::fetchPublishedForm($formId); if ($form === null) { return GutenbergBlockRenderer::renderFormNotFound(); } return GutenbergBlockRenderer::renderFormBlock($formId, $attributes); } }