wp = $wp;
$this->featuresController = $featuresController;
$this->emailApiController = $emailApiController;
$this->cli = $cli;
}
public function initialize(): void {
if (!$this->featuresController->isSupported(FeaturesController::GUTENBERG_EMAIL_EDITOR)) {
return;
}
$this->cli->initialize();
$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(),
]);
}
public function getEmailDefaultContent(): string {
return '
' . esc_html__('You received this email because you are subscribed to the [site:title]', 'mailpoet') . '
' . esc_html__('Unsubscribe', 'mailpoet') . ' | ' . esc_html__('Manage subscription', 'mailpoet') . '
'; } }