span { width: 5px; height: 5px; background-color: #5b5b5b; } EOL; /** @var CdnAssetUrl */ protected $cdnAssetUrl; /** @var WPFunctions */ protected $wp; /** @var string */ protected $assetsDirectory = ''; /** @var SettingsController */ private $settings; public function __construct( CdnAssetUrl $cdnAssetUrl, SettingsController $settings, WPFunctions $wp ) { $this->cdnAssetUrl = $cdnAssetUrl; $this->wp = $wp; $this->settings = $settings; } abstract public function getName(): string; abstract public function getBody(): array; abstract public function getThumbnailUrl(): string; public function getSettings(): array { return [ 'on_success' => 'message', 'success_message' => '', 'segments' => null, 'segments_selected_by' => 'admin', ]; } public function getStyles(): string { return self::DEFAULT_STYLES; } public function toFormEntity(): FormEntity { $formEntity = new FormEntity($this->getName()); $formEntity->setBody($this->getBody()); $formEntity->setSettings($this->getSettings()); $formEntity->setStyles($this->getStyles()); $settings = $formEntity->getSettings(); if (!isset($settings['success_message']) || !($settings['success_message'])) { $settings['success_message'] = $this->getDefaultSuccessMessage(); $formEntity->setSettings($settings); } return $formEntity; } private function getDefaultSuccessMessage() { if ($this->settings->get('signup_confirmation.enabled')) { return __('Check your inbox or spam folder to confirm your subscription.', 'mailpoet'); } return __('You’ve been successfully subscribed to our newsletter!', 'mailpoet'); } protected function getAssetUrl(string $filename): string { return $this->cdnAssetUrl->generateCdnUrl("form-templates/{$this->assetsDirectory}/$filename"); } protected function replaceLinkTags($source, $link, $attributes = [], $linkTag = false): string { return Helpers::replaceLinkTags($source, $link, $attributes, $linkTag); } protected function replacePrivacyLinkTags($source, $link = '#'): string { $privacyPolicyUrl = $this->wp->getPrivacyPolicyUrl(); $attributes = []; $linkTag = false; if (!empty($privacyPolicyUrl)) { $link = $this->wp->escUrl($privacyPolicyUrl); $attributes = ['target' => '_blank']; $linkTag = 'link'; } return $this->replaceLinkTags($source, $link, $attributes, $linkTag); } }