diff --git a/mailpoet/lib/Automation/Engine/Builder/UpdateWorkflowController.php b/mailpoet/lib/Automation/Engine/Builder/UpdateWorkflowController.php index b04a26a15c..3f8d536bb8 100644 --- a/mailpoet/lib/Automation/Engine/Builder/UpdateWorkflowController.php +++ b/mailpoet/lib/Automation/Engine/Builder/UpdateWorkflowController.php @@ -56,6 +56,7 @@ class UpdateWorkflowController { $this->updateStepsController->updateSteps($workflow, $data['steps']); foreach ($workflow->getSteps() as $step) { $this->hooks->doWorkflowStepBeforeSave($step); + $this->hooks->doWorkflowStepByKeyBeforeSave($step); } $changed = true; } diff --git a/mailpoet/lib/Automation/Engine/Hooks.php b/mailpoet/lib/Automation/Engine/Hooks.php index 8d535cb6e0..d169d49924 100644 --- a/mailpoet/lib/Automation/Engine/Hooks.php +++ b/mailpoet/lib/Automation/Engine/Hooks.php @@ -31,4 +31,8 @@ class Hooks { public function doWorkflowStepBeforeSave(Step $step): void { $this->wordPress->doAction(self::WORKFLOW_STEP_BEFORE_SAVE, $step); } + + public function doWorkflowStepByKeyBeforeSave(Step $step): void { + $this->wordPress->doAction(self::WORKFLOW_STEP_BEFORE_SAVE . '/key=' . $step->getKey(), $step); + } } diff --git a/mailpoet/lib/Automation/Engine/Registry.php b/mailpoet/lib/Automation/Engine/Registry.php index 8c291eb197..a4502eec69 100644 --- a/mailpoet/lib/Automation/Engine/Registry.php +++ b/mailpoet/lib/Automation/Engine/Registry.php @@ -105,7 +105,8 @@ class Registry { $this->wordPress->addAction(Hooks::WORKFLOW_BEFORE_SAVE, $callback, $priority); } - public function onBeforeWorkflowStepSave(callable $callback, int $priority = 10): void { - $this->wordPress->addAction(Hooks::WORKFLOW_STEP_BEFORE_SAVE, $callback, $priority); + public function onBeforeWorkflowStepSave(callable $callback, string $key = null, int $priority = 10): void { + $keyPart = $key ? "/key=$key" : ''; + $this->wordPress->addAction(Hooks::WORKFLOW_STEP_BEFORE_SAVE . $keyPart, $callback, $priority); } } diff --git a/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php b/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php index b9393aa943..1943247163 100644 --- a/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php +++ b/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php @@ -119,10 +119,6 @@ class SendEmailAction implements Action { } public function saveEmailSettings(Step $step): void { - if ($step->getKey() !== $this->getKey()) { - return; - } - $args = $step->getArgs(); if (!isset($args['email_id'])) { return; diff --git a/mailpoet/lib/Automation/Integrations/MailPoet/MailPoetIntegration.php b/mailpoet/lib/Automation/Integrations/MailPoet/MailPoetIntegration.php index f0c42e92db..7b5a932bd7 100644 --- a/mailpoet/lib/Automation/Integrations/MailPoet/MailPoetIntegration.php +++ b/mailpoet/lib/Automation/Integrations/MailPoet/MailPoetIntegration.php @@ -41,6 +41,9 @@ class MailPoetIntegration implements Integration { $registry->addAction($this->sendEmailAction); // sync step args (subject, preheader, etc.) to email settings - $registry->onBeforeWorkflowStepSave([$this->sendEmailAction, 'saveEmailSettings']); + $registry->onBeforeWorkflowStepSave( + [$this->sendEmailAction, 'saveEmailSettings'], + $this->sendEmailAction->getKey() + ); } }