wp = $wp; $this->formsRepository = $formsRepository; } public function init() { $this->wp->registerBlockType('mailpoet/subscription-form-block-render', [ 'attributes' => [ 'formId' => [ 'type' => 'number', 'default' => null, ], ], 'render_callback' => [$this, 'renderForm'], ]); } public function initAdmin() { $this->wp->registerBlockType('mailpoet/subscription-form-block', [ 'style' => 'mailpoetblock-form-block-css', 'editor_script' => 'mailpoet/subscription-form-block', ]); $this->wp->addAction('admin_head', function() { $forms = $this->formsRepository->findAllNotDeleted(); ?> wp->registerBlockType('mailpoet/subscription-form-block', [ 'render_callback' => [$this, 'renderForm'], ]); } public function renderForm(array $attributes = []): string { if (!$attributes || !isset($attributes['formId'])) { return ''; } $basicForm = new Widget(); return $basicForm->widget([ 'form' => (int)$attributes['formId'], 'form_type' => 'html', ]); } }