| @@ -6,13 +6,50 @@ | ||
| 6 | 6 | use AcyMailing\Helpers\MailerHelper; |
| 7 | 7 | |
| 8 | 8 | trait ForwardMailboxAction |
| 9 | 9 | { |
| 10 | - public function onAcymMailboxActionDefine(&$actions) | |
| 10 | + protected function initMailboxActions(): void | |
| 11 | 11 | { |
| 12 | + $this->mailboxActions = [ | |
| 13 | + 'forward_specific' => acym_translation('ACYM_FORWARD_EMAIL'), | |
| 14 | + 'forward_list' => acym_translation('ACYM_FORWARD_TO_A_LIST'), | |
| 15 | + ]; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public function displayMailboxActionOptions_forward_specific(string $fieldName): void | |
| 19 | + { | |
| 20 | + ?> | |
| 21 | + <input type="text" | |
| 22 | + name="<?php echo esc_attr($fieldName.'[addresses]'); ?>" | |
| 23 | + placeholder="[email protected],[email protected]"><br /> | |
| 24 | + <?php | |
| 25 | + $this->displayForwardTemplateChoice($fieldName); | |
| 26 | + } | |
| 27 | + | |
| 28 | + public function displayMailboxActionOptions_forward_list(string $fieldName): void | |
| 29 | + { | |
| 12 | 30 | $listClass = new ListClass(); |
| 13 | - $lists = $listClass->getAllWithIdName(); | |
| 31 | + ?> | |
| 32 | + <div class="intext_select_mailbox cell"> | |
| 33 | + <?php acym_select( | |
| 34 | + $listClass->getAllWithIdName(), | |
| 35 | + $fieldName.'[list_id]', | |
| 36 | + null, | |
| 37 | + ['class' => 'acym__select'], | |
| 38 | + 'value', | |
| 39 | + 'text', | |
| 40 | + null, | |
| 41 | + false, | |
| 42 | + true | |
| 43 | + ); ?> | |
| 44 | + </div> | |
| 45 | + <br /><br /> | |
| 46 | + <?php | |
| 47 | + $this->displayForwardTemplateChoice($fieldName); | |
| 48 | + } | |
| 14 | 49 | |
| 50 | + private function displayForwardTemplateChoice(string $fieldName): void | |
| 51 | + { | |
| 15 | 52 | $mailClass = new MailClass(); |
| 16 | 53 | $templates = $mailClass->getTemplatesForMailboxAction(); |
| 17 | 54 | |
| 18 | 55 | $firstOption = new stdClass(); |
| @@ -19,52 +56,21 @@ | ||
| 19 | 56 | $firstOption->id = 0; |
| 20 | 57 | $firstOption->name = acym_translation('ACYM_CHOOSE_TEMPLATE'); |
| 21 | 58 | array_unshift($templates, $firstOption); |
| 22 | 59 | |
| 23 | - $actions['forward_specific'] = new stdClass(); | |
| 24 | - $actions['forward_specific']->name = acym_translation('ACYM_FORWARD_EMAIL'); | |
| 25 | - $actions['forward_specific']->option = '<input type="text" | |
| 26 | - name="acym_action[__num__][forward_specific][addresses]" | |
| 27 | - placeholder="[email protected],[email protected]"><br />'; | |
| 28 | - $actions['forward_specific']->option .= acym_translationSprintf( | |
| 29 | - 'ACYM_INCLUDE_IN_TEMPLATE', | |
| 30 | - '<div class="intext_select_mailbox cell">'.acym_select( | |
| 60 | + $templateSelect = '<div class="intext_select_mailbox cell">'.acym_select( | |
| 31 | 61 | $templates, |
| 32 | - 'acym_action[__num__][forward_specific][template_id]', | |
| 62 | + $fieldName.'[template_id]', | |
| 33 | 63 | null, |
| 34 | 64 | ['class' => 'acym__select'], |
| 35 | 65 | 'id', |
| 36 | 66 | 'name' |
| 37 | - ).'</div>' | |
| 38 | - ); | |
| 39 | - ob_start(); | |
| 40 | - acym_info(['textShownInTooltip' => 'ACYM_INCLUDE_IN_TEMPLATE_DESC']); | |
| 41 | - $actions['forward_specific']->option .= ob_get_clean(); | |
| 67 | + ).'</div>'; | |
| 42 | 68 | |
| 43 | - $actions['forward_list'] = new stdClass(); | |
| 44 | - $actions['forward_list']->name = acym_translation('ACYM_FORWARD_TO_A_LIST'); | |
| 45 | - $actions['forward_list']->option = '<div class="intext_select_mailbox cell">'; | |
| 46 | - $actions['forward_list']->option .= acym_select( | |
| 47 | - $lists, | |
| 48 | - 'acym_action[__num__][forward_list][list_id]', | |
| 49 | - null, | |
| 50 | - ['class' => 'acym__select'] | |
| 51 | - ); | |
| 52 | - $actions['forward_list']->option .= '</div><br /><br />'; | |
| 53 | - $actions['forward_list']->option .= acym_translationSprintf( | |
| 54 | - 'ACYM_INCLUDE_IN_TEMPLATE', | |
| 55 | - '<div class="intext_select_mailbox cell">'.acym_select( | |
| 56 | - $templates, | |
| 57 | - 'acym_action[__num__][forward_list][template_id]', | |
| 58 | - null, | |
| 59 | - ['class' => 'acym__select'], | |
| 60 | - 'id', | |
| 61 | - 'name' | |
| 62 | - ).'</div>' | |
| 63 | - ); | |
| 64 | - ob_start(); | |
| 69 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- The select is built and escaped by acym_select just above, and its position in the sentence depends on the language. | |
| 70 | + echo acym_translationSprintf('ACYM_INCLUDE_IN_TEMPLATE', $templateSelect); | |
| 71 | + | |
| 65 | 72 | acym_info(['textShownInTooltip' => 'ACYM_INCLUDE_IN_TEMPLATE_DESC']); |
| 66 | - $actions['forward_list']->option .= ob_get_clean(); | |
| 67 | 73 | } |
| 68 | 74 | |
| 69 | 75 | public function onAcymMailboxActionSummaryListing(&$action, &$result) |
| 70 | 76 | { |