PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.9.0
GiveWP – Donation Plugin and Fundraising Platform v3.9.0
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 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / src / DonationForms / Properties / FormSettings.php
give / src / DonationForms / Properties Last commit date
FormSettings.php 2 years ago
FormSettings.php
388 lines
1 <?php
2
3 namespace Give\DonationForms\Properties;
4
5 use Give\DonationForms\ValueObjects\DesignSettingsImageStyle;
6 use Give\DonationForms\ValueObjects\DesignSettingsLogoPosition;
7 use Give\DonationForms\ValueObjects\DesignSettingsSectionStyle;
8 use Give\DonationForms\ValueObjects\DesignSettingsTextFieldStyle;
9 use Give\DonationForms\ValueObjects\DonationFormStatus;
10 use Give\DonationForms\ValueObjects\GoalType;
11 use Give\Framework\Support\Contracts\Arrayable;
12 use Give\Framework\Support\Contracts\Jsonable;
13
14 /**
15 * @since 3.2.0 Remove addSlashesRecursive method
16 * @since 3.0.0
17 */
18 class FormSettings implements Arrayable, Jsonable
19 {
20 /**
21 * @var boolean
22 */
23 public $showHeader;
24 /**
25 * @var boolean
26 */
27 public $showHeading;
28 /**
29 * @var boolean
30 */
31 public $showDescription;
32 /**
33 * @var string
34 */
35 public $formTitle;
36 /**
37 * @var boolean
38 */
39 public $enableDonationGoal;
40 /**
41 * @var boolean
42 */
43 public $enableAutoClose;
44 /**
45 * @var GoalType
46 */
47 public $goalType;
48 /**
49 * @var string
50 */
51 public $designId;
52 /**
53 * @var string
54 */
55 public $heading;
56 /**
57 * @var string
58 */
59 public $description;
60 /**
61 * @var string
62 */
63 public $primaryColor;
64 /**
65 * @var string
66 */
67 public $secondaryColor;
68 /**
69 * @var float
70 */
71 public $goalAmount;
72 /**
73 * @since 3.2.0 Added registrationNotification property.
74 * @var string
75 */
76 public $registrationNotification;
77 /**
78 * @var string
79 */
80 public $customCss;
81 /**
82 * @var string
83 */
84 public $goalAchievedMessage;
85
86 /**
87 * @var string
88 */
89 public $pageSlug;
90
91 /**
92 * @var string
93 */
94 public $receiptHeading;
95
96 /**
97 * @var string
98 */
99 public $receiptDescription;
100
101 /**
102 * @var DonationFormStatus
103 */
104 public $formStatus;
105
106 /**
107 * @var array
108 */
109 public $emailTemplateOptions;
110
111 /**
112 * @var string
113 * @todo Extract to a value object.
114 */
115 public $emailOptionsStatus;
116
117 /**
118 * @var string
119 */
120 public $emailTemplate;
121
122 /**
123 * @var string
124 */
125 public $emailLogo;
126
127 /**
128 * @var string
129 */
130 public $emailFromName;
131
132 /**
133 * @var string
134 */
135 public $emailFromEmail;
136
137 /**
138 * @var boolean
139 */
140 public $formGridCustomize;
141
142 /**
143 * @var string
144 */
145 public $formGridRedirectUrl;
146
147 /**
148 * @var string
149 */
150 public $formGridDonateButtonText;
151
152 /**
153 * @var boolean
154 */
155 public $formGridHideDocumentationLink;
156
157 /**
158 * @var boolean
159 */
160 public $offlineDonationsCustomize;
161
162 /**
163 * @var string
164 */
165 public $offlineDonationsInstructions;
166
167 /**
168 * @var string
169 */
170 public $donateButtonCaption;
171 /**
172 * @var string
173 */
174 public $multiStepFirstButtonText;
175 /**
176 * @var string
177 */
178 public $multiStepNextButtonText;
179
180 /**
181 * @var array
182 */
183 public $pdfSettings;
184
185 /**
186 * @since 3.4.0
187 * @var string
188 */
189 public $designSettingsImageUrl;
190
191 /**
192 * @since 3.4.0
193 * @var string
194 */
195 public $designSettingsImageStyle;
196
197 /**
198 * @since 3.4.0
199 * @var string
200 */
201 public $designSettingsLogoUrl;
202
203 /**
204 * @since 3.4.0
205 * @var string
206 */
207 public $designSettingsLogoPosition;
208
209 /**
210 * @since 3.4.0
211 * @var string
212 */
213 public $designSettingsSectionStyle;
214
215 /**
216 * @since 3.4.0
217 * @var string
218 */
219 public $designSettingsTextFieldStyle;
220
221 /**
222 * @since 3.6.0
223 * @var string
224 */
225 public $designSettingsImageColor;
226
227 /**
228 * @since 3.6.0
229 * @var string
230 */
231 public $designSettingsImageOpacity;
232
233 /**
234 * @since 3.7.0
235 * @var string
236 */
237 public $formExcerpt;
238
239 /**
240 * @since 3.9.0
241 * @var array
242 */
243 public $currencySwitcherSettings;
244
245 /**
246 * @since 3.7.0 Added formExcerpt
247
248 /**
249 * @since 3.2.0 Added registrationNotification
250 * @since 3.0.0
251 */
252 public static function fromArray(array $array): self
253 {
254 $self = new self();
255
256 $self->showHeader = $array['showHeader'] ?? true;
257 $self->showHeading = $array['showHeading'] ?? true;
258 $self->heading = $array['heading'] ?? __('Support Our Cause', 'give');
259 $self->showDescription = $array['showDescription'] ?? true;
260 $self->description = $array['description'] ?? __(
261 'Help our organization by donating today! Donations go to making a difference for our cause.',
262 'give'
263 );
264 $self->formTitle = $array['formTitle'] ?? __('Donation Form', 'give');
265 $self->donateButtonCaption = $array['donateButtonCaption'] ?? __('Donate now', 'give');
266 $self->enableDonationGoal = $array['enableDonationGoal'] ?? false;
267 $self->enableAutoClose = $array['enableAutoClose'] ?? false;
268 $self->goalType = ! empty($array['goalType']) && GoalType::isValid($array['goalType']) ? new GoalType(
269 $array['goalType']
270 ) : GoalType::AMOUNT();
271 $self->designId = $array['designId'] ?? null;
272 $self->primaryColor = $array['primaryColor'] ?? '#69b86b';
273 $self->secondaryColor = $array['secondaryColor'] ?? '#f49420';
274 $self->goalAmount = $array['goalAmount'] ?? 0;
275 $self->registrationNotification = $array['registrationNotification'] ?? false;
276 $self->customCss = $array['customCss'] ?? '';
277 $self->pageSlug = $array['pageSlug'] ?? '';
278 $self->goalAchievedMessage = $array['goalAchievedMessage'] ?? __(
279 'Thank you to all our donors, we have met our fundraising goal.',
280 'give'
281 );
282 $self->receiptHeading = $array['receiptHeading'] ?? __(
283 'Hey {first_name}, thanks for your donation!',
284 'give'
285 );
286 $self->receiptDescription = $array['receiptDescription'] ?? __(
287 '{first_name}, your contribution means a lot and will be put to good use in making a difference. We’ve sent your donation receipt to {email}.',
288 'give'
289 );
290 $self->formStatus = ! empty($array['formStatus']) ? new DonationFormStatus(
291 $array['formStatus']
292 ) : DonationFormStatus::DRAFT();
293
294 $self->formGridCustomize = $array['formGridCustomize'] ?? false;
295 $self->formGridRedirectUrl = $array['formGridRedirectUrl'] ?? '';
296 $self->formGridDonateButtonText = $array['formGridDonateButtonText'] ?? '';
297 $self->formGridHideDocumentationLink = $array['formGridHideDocumentationLink'] ?? false;
298
299 $self->emailTemplateOptions = $array['emailTemplateOptions'] ?? [];
300
301 $self->emailOptionsStatus = $array['emailOptionsStatus'] ?? 'global';
302
303 $self->emailTemplate = $array['emailTemplate'] ?? 'default';
304
305 $self->emailFromName = $array['emailFromName'] ?? '';
306
307 $self->emailFromEmail = $array['emailFromEmail'] ?? '';
308
309 $self->emailLogo = $array['emailLogo'] ?? '';
310
311 $self->offlineDonationsCustomize = $array['offlineDonationsCustomize'] ?? false;
312
313 $self->offlineDonationsInstructions = $array['offlineDonationsInstructions'] ?? '';
314
315 $self->multiStepFirstButtonText = $array['multiStepFirstButtonText'] ?? __('Donate now', 'give');
316
317 $self->multiStepNextButtonText = $array['multiStepNextButtonText'] ?? __('Continue', 'give');
318
319 $self->pdfSettings = isset($array['pdfSettings']) && is_array(
320 $array['pdfSettings']
321 ) ? $array['pdfSettings'] : [];
322
323 $self->designSettingsImageUrl = $array['designSettingsImageUrl'] ?? '';
324 $self->designSettingsImageStyle = ! empty($array['designSettingsImageStyle']) ? new DesignSettingsImageStyle(
325 $array['designSettingsImageStyle']
326 ) : DesignSettingsImageStyle::BACKGROUND();
327
328 $self->designSettingsLogoUrl = $array['designSettingsLogoUrl'] ?? '';
329 $self->designSettingsLogoPosition = ! empty($array['designSettingsLogoPosition']) ? new DesignSettingsLogoPosition(
330 $array['designSettingsLogoPosition']
331 ) : DesignSettingsLogoPosition::LEFT();
332
333 $self->designSettingsSectionStyle = ! empty($array['designSettingsSectionStyle']) ? new DesignSettingsSectionStyle(
334 $array['designSettingsSectionStyle']
335 ) : DesignSettingsSectionStyle::DEFAULT();
336
337 $self->designSettingsTextFieldStyle = ! empty($array['designSettingsTextFieldStyle']) ? new DesignSettingsTextFieldStyle(
338 $array['designSettingsTextFieldStyle']
339 ) : DesignSettingsTextFieldStyle::DEFAULT();
340
341 $self->designSettingsImageColor = $array['designSettingsImageColor'] ?? '';
342
343 $self->designSettingsImageOpacity = $array['designSettingsImageOpacity'] ?? '';
344
345 $self->formExcerpt = $array['formExcerpt'] ?? '';
346
347 $self->currencySwitcherSettings = isset($array['currencySwitcherSettings']) && is_array(
348 $array['currencySwitcherSettings']
349 ) ? $array['currencySwitcherSettings'] : [];
350
351 return $self;
352 }
353
354 /**
355 * @since 3.0.0
356 */
357 public static function fromJson(string $json): self
358 {
359 return self::fromArray(
360 json_decode($json, true)
361 );
362 }
363
364 /**
365 * @since 3.0.0
366 */
367 public function toArray(): array
368 {
369 return get_object_vars($this);
370 }
371
372 /**
373 * @since 3.2.0 Remove call to addSlashesRecursive method for emailTemplateOptions in favor of SanitizeDonationFormPreviewRequest class
374 * @since 3.0.0
375 */
376 public function toJson($options = 0): string
377 {
378 return json_encode(
379 array_merge(
380 $this->toArray(),
381 [
382 'goalType' => $this->goalType ? $this->goalType->getValue() : null,
383 ]
384 )
385 );
386 }
387 }
388