<?php declare(strict_types = 1); namespace MailPoet\Form; if (!defined('ABSPATH')) exit; use MailPoet\Entities\FormEntity; use MailPoet\Settings\SettingsController; class FormMessageController { /** @var FormsRepository */ private $formsRepository; /** @var SettingsController */ private $settings; public function __construct( FormsRepository $formsRepository, SettingsController $settingsController ) { $this->formsRepository = $formsRepository; $this->settings = $settingsController; } public function updateSuccessMessages(): void { $rightMessage = $this->getDefaultSuccessMessage(); $wrongMessage = ( $rightMessage === __('Check your inbox or spam folder to confirm your subscription.', 'mailpoet') ? __('You’ve been successfully subscribed to our newsletter!', 'mailpoet') : __('Check your inbox or spam folder to confirm your subscription.', 'mailpoet') ); /** @var FormEntity[] $forms */ $forms = $this->formsRepository->findAll(); foreach ($forms as $form) { $settings = $form->getSettings(); if (isset($settings['success_message']) && $settings['success_message'] === $wrongMessage) { $settings['success_message'] = $rightMessage; $form->setSettings($settings); $this->formsRepository->flush(); } } } public function getDefaultSuccessMessage(): string { 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'); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Block | Folder | 0755 |
|
|
Listing | Folder | 0755 |
|
|
Templates | Folder | 0755 |
|
|
Util | Folder | 0755 |
|
|
ApiDataSanitizer.php | File | 1.82 KB | 0644 |
|
AssetsController.php | File | 3.38 KB | 0644 |
|
BlockStylesRenderer.php | File | 3.79 KB | 0644 |
|
BlockWrapperRenderer.php | File | 548 B | 0644 |
|
BlocksRenderer.php | File | 3.98 KB | 0644 |
|
DisplayFormInWPContent.php | File | 7.77 KB | 0644 |
|
FormFactory.php | File | 1.69 KB | 0644 |
|
FormHtmlSanitizer.php | File | 1.11 KB | 0644 |
|
FormMessageController.php | File | 1.61 KB | 0644 |
|
FormSaveController.php | File | 1021 B | 0644 |
|
FormsRepository.php | File | 2.52 KB | 0644 |
|
PreviewPage.php | File | 3.91 KB | 0644 |
|
PreviewWidget.php | File | 472 B | 0644 |
|
Renderer.php | File | 4.05 KB | 0644 |
|
Widget.php | File | 8.34 KB | 0644 |
|
index.php | File | 0 B | 0644 |
|