Update forms messages on settings save [MAILPOET-1636]
This commit is contained in:
committed by
M. Shull
parent
64e1a1e16c
commit
db17281705
@ -11,6 +11,7 @@ use MailPoet\Models\ScheduledTask;
|
|||||||
use MailPoet\Services\Bridge;
|
use MailPoet\Services\Bridge;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
|
use MailPoet\Models\Form;
|
||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ class Settings extends APIEndpoint {
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$original_inactivation_interval = (int)$this->settings->get('deactivate_subscriber_after_inactive_days');
|
$original_inactivation_interval = (int)$this->settings->get('deactivate_subscriber_after_inactive_days');
|
||||||
|
$signup_confirmation = $this->settings->get('signup_confirmation.enabled');
|
||||||
foreach ($settings as $name => $value) {
|
foreach ($settings as $name => $value) {
|
||||||
$this->settings->set($name, $value);
|
$this->settings->set($name, $value);
|
||||||
}
|
}
|
||||||
@ -50,6 +52,9 @@ class Settings extends APIEndpoint {
|
|||||||
}
|
}
|
||||||
$bridge = new Bridge();
|
$bridge = new Bridge();
|
||||||
$bridge->onSettingsSave($settings);
|
$bridge->onSettingsSave($settings);
|
||||||
|
if ($signup_confirmation != $this->settings->get('signup_confirmation.enabled')) {
|
||||||
|
Form::updateSuccessMessages();
|
||||||
|
}
|
||||||
return $this->successResponse($this->settings->getAll());
|
return $this->successResponse($this->settings->getAll());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,4 +132,21 @@ class Form extends Model {
|
|||||||
return WPFunctions::get()->__(self::MESSAGE_WHEN_CONFIRMATION_DISABLED, 'mailpoet');
|
return WPFunctions::get()->__(self::MESSAGE_WHEN_CONFIRMATION_DISABLED, 'mailpoet');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function updateSuccessMessages() {
|
||||||
|
$right_message = self::getDefaultSuccessMessage();
|
||||||
|
$wrong_message = (
|
||||||
|
$right_message === self::MESSAGE_WHEN_CONFIRMATION_ENABLED
|
||||||
|
? self::MESSAGE_WHEN_CONFIRMATION_DISABLED
|
||||||
|
: self::MESSAGE_WHEN_CONFIRMATION_ENABLED
|
||||||
|
);
|
||||||
|
$forms = self::findMany();
|
||||||
|
foreach ($forms as $form) {
|
||||||
|
$data = $form->asArray();
|
||||||
|
if (isset($data['settings']['success_message']) && $data['settings']['success_message'] === $wrong_message) {
|
||||||
|
$data['settings']['success_message'] = $right_message;
|
||||||
|
self::createOrUpdate($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user