PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / FormBuilder / Actions / UpdateEmailTemplateMeta.php

UpdateEmailTemplateMeta.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/FormBuilder/Actions/UpdateEmailTemplateMeta.php

47 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\FormBuilder\Actions;
4
5 use Give\DonationForms\Models\DonationForm;
6
7 /**
8 * Update email template options on backwards compatible form meta.
9 *
10 * @since 3.0.0
11 */
12 class UpdateEmailTemplateMeta
13 {
14 /**
15 * @since 3.0.0
16 * @param DonationForm $form
17 */
18 public function __invoke(DonationForm $form)
19 {
20 foreach($form->settings->emailTemplateOptions as $emailType => $templateOptions) {
21
22 $templateOptions['notification'] = $templateOptions['status'];
23 unset($templateOptions['status']);
24
25 if(isset($templateOptions['recipient'])) {
26 $templateOptions['recipient'] = $this->formatRecipientEmails($templateOptions['recipient']);
27 }
28
29 foreach($templateOptions as $key => $value) {
30 give()->form_meta->update_meta($form->id, "_give_{$emailType}_{$key}", $value);
31 }
32 }
33 }
34
35 /**
36 * @since 3.0.0
37 * @param array $emails
38 * @return array
39 */
40 protected function formatRecipientEmails($emails): array
41 {
42 return array_map(function($email) {
43 return ['email' => $email];
44 }, $emails);
45 }
46 }
47