wp = $wp; $this->featuresController = $featuresController; $this->emailApiController = $emailApiController; } public function initialize(): void { if (!$this->featuresController->isSupported(FeaturesController::GUTENBERG_EMAIL_EDITOR)) { return; } $this->wp->addFilter('mailpoet_email_editor_post_types', [$this, 'addEmailPostType']); $this->extendEmailPostApi(); } public function addEmailPostType(array $postTypes): array { $postTypes[] = [ 'name' => self::MAILPOET_EMAIL_POST_TYPE, 'args' => [ 'labels' => [ 'name' => __('Emails', 'mailpoet'), 'singular_name' => __('Email', 'mailpoet'), ], 'rewrite' => ['slug' => self::MAILPOET_EMAIL_POST_TYPE], ], ]; return $postTypes; } public function extendEmailPostApi() { $this->wp->registerRestField(self::MAILPOET_EMAIL_POST_TYPE, 'mailpoet_data', [ 'get_callback' => [$this->emailApiController, 'getEmailData'], 'update_callback' => [$this->emailApiController, 'saveEmailData'], 'schema' => $this->emailApiController->getEmailDataSchema(), ]); } }