PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 4.14.3
GiveWP – Donation Plugin and Fundraising Platform v4.14.3
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 5 months ago GoalSettings.php 1 year ago
FormSettings.php
446 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\GoalProgressType;
11 use Give\DonationForms\ValueObjects\GoalSource;
12 use Give\DonationForms\ValueObjects\GoalType;
13 use Give\Framework\Support\Contracts\Arrayable;
14 use Give\Framework\Support\Contracts\Jsonable;
15
16 /**
17 * @since 4.3.0 Update default value for Primary color to improve accessibility color contrast.
18 * @since 3.16.0 Added $enableReceiptConfirmationPage property
19 * @since 3.12.0 Add goalProgressType
20 * @since 3.2.0 Remove addSlashesRecursive method
21 * @since 3.0.0
22 */
23 class FormSettings implements Arrayable, Jsonable
24 {
25 /**
26 * @var boolean
27 */
28 public $showHeader;
29 /**
30 * @var boolean
31 */
32 public $showHeading;
33 /**
34 * @var boolean
35 */
36 public $showDescription;
37 /**
38 * @var string
39 */
40 public $formTitle;
41 /**
42 * @var boolean
43 */
44 public $enableDonationGoal;
45 /**
46 * @var boolean
47 */
48 public $enableAutoClose;
49 /**
50 * @since 4.1.0
51 *
52 * @var GoalSource
53 */
54 public $goalSource;
55 /**
56 * @var GoalType
57 */
58 public $goalType;
59 /**
60 * @var GoalProgressType
61 */
62 public $goalProgressType;
63 /**
64 * @var string
65 */
66 public $goalStartDate;
67 /**
68 * @var string
69 */
70 public $goalEndDate;
71 /**
72 * @var string
73 */
74 public $designId;
75 /**
76 * @var string
77 */
78 public $heading;
79 /**
80 * @var string
81 */
82 public $description;
83 /**
84 * @var string
85 */
86 public $primaryColor;
87 /**
88 * @var string
89 */
90 public $secondaryColor;
91 /**
92 * @var float
93 */
94 public $goalAmount;
95 /**
96 * @since 3.2.0 Added registrationNotification property.
97 * @var string
98 */
99 public $registrationNotification;
100 /**
101 * @var string
102 */
103 public $customCss;
104 /**
105 * @var string
106 */
107 public $goalAchievedMessage;
108
109 /**
110 * @var string
111 */
112 public $pageSlug;
113
114 /**
115 * @var string
116 */
117 public $receiptHeading;
118
119 /**
120 * @var string
121 */
122 public $receiptDescription;
123
124 /**
125 * @var DonationFormStatus
126 */
127 public $formStatus;
128
129 /**
130 * @var array
131 */
132 public $emailTemplateOptions;
133
134 /**
135 * @var string
136 * @todo Extract to a value object.
137 */
138 public $emailOptionsStatus;
139
140 /**
141 * @var string
142 */
143 public $emailTemplate;
144
145 /**
146 * @var string
147 */
148 public $emailLogo;
149
150 /**
151 * @var string
152 */
153 public $emailFromName;
154
155 /**
156 * @var string
157 */
158 public $emailFromEmail;
159
160 /**
161 * @var boolean
162 */
163 public $formGridCustomize;
164
165 /**
166 * @var string
167 */
168 public $formGridRedirectUrl;
169
170 /**
171 * @var string
172 */
173 public $formGridDonateButtonText;
174
175 /**
176 * @var boolean
177 */
178 public $formGridHideDocumentationLink;
179
180 /**
181 * @var boolean
182 */
183 public $offlineDonationsCustomize;
184
185 /**
186 * @var string
187 */
188 public $offlineDonationsInstructions;
189
190 /**
191 * @var string
192 */
193 public $donateButtonCaption;
194 /**
195 * @var string
196 */
197 public $multiStepFirstButtonText;
198 /**
199 * @var string
200 */
201 public $multiStepNextButtonText;
202
203 /**
204 * @var array
205 */
206 public $pdfSettings;
207
208 /**
209 * @since 3.4.0
210 * @var string
211 */
212 public $designSettingsImageUrl;
213
214 /**
215 * @since 3.11.0
216 * @var string
217 */
218 public $designSettingsImageAlt;
219
220 /**
221 * @since 3.4.0
222 * @var string
223 */
224 public $designSettingsImageStyle;
225
226 /**
227 * @since 3.4.0
228 * @var string
229 */
230 public $designSettingsLogoUrl;
231
232 /**
233 * @since 3.4.0
234 * @var string
235 */
236 public $designSettingsLogoPosition;
237
238 /**
239 * @since 3.4.0
240 * @var string
241 */
242 public $designSettingsSectionStyle;
243
244 /**
245 * @since 3.4.0
246 * @var string
247 */
248 public $designSettingsTextFieldStyle;
249
250 /**
251 * @since 3.6.0
252 * @var string
253 */
254 public $designSettingsImageColor;
255
256 /**
257 * @since 3.6.0
258 * @var string
259 */
260 public $designSettingsImageOpacity;
261
262 /**
263 * @since 3.7.0
264 * @var string
265 */
266 public $formExcerpt;
267
268 /**
269 * @since 3.9.0
270 * @var array
271 */
272 public $currencySwitcherSettings;
273
274 /**
275 * @since 3.16.0
276 * @var bool
277 */
278 public $enableReceiptConfirmationPage;
279
280 /**
281 * @since 4.1.0 Added goalSource
282 * @since 4.1.0
283 */
284 public bool $inheritCampaignColors;
285
286 /**
287 * @since 4.14.3 Sanitize designId property
288 * @since 4.1.0 Added $inheritCampaignColors
289 * @since 3.16.0 Added $enableReceiptConfirmationPage
290 * @since 3.7.0 Added formExcerpt
291 * @since 3.11.0 Sanitize customCSS property
292 * @since 3.2.0 Added registrationNotification
293 * @since 3.0.0
294 */
295 public static function fromArray(array $array): self
296 {
297 $self = new self();
298
299 $self->showHeader = $array['showHeader'] ?? true;
300 $self->showHeading = $array['showHeading'] ?? true;
301 $self->heading = $array['heading'] ?? __('Support Our Cause', 'give');
302 $self->showDescription = $array['showDescription'] ?? true;
303 $self->description = $array['description'] ?? __(
304 'Help our organization by donating today! Donations go to making a difference for our cause.',
305 'give'
306 );
307 $self->formTitle = $array['formTitle'] ?? __('Donation Form', 'give');
308 $self->donateButtonCaption = $array['donateButtonCaption'] ?? __('Donate now', 'give');
309 $self->enableDonationGoal = $array['enableDonationGoal'] ?? false;
310 $self->enableAutoClose = $array['enableAutoClose'] ?? false;
311 $self->goalSource = ! empty($array['goalSource']) && GoalSource::isValid($array['goalSource'])
312 ? new GoalSource($array['goalSource'])
313 : GoalSource::FORM();
314 $self->goalType = ! empty($array['goalType']) && GoalType::isValid($array['goalType']) ? new GoalType(
315 $array['goalType']
316 ) : GoalType::AMOUNT();
317 $self->goalProgressType = ! empty($array['goalProgressType']) && GoalProgressType::isValid($array['goalProgressType'])
318 ? new GoalProgressType($array['goalProgressType'])
319 : GoalProgressType::ALL_TIME();
320 $self->goalStartDate = $array['goalStartDate'] ?? '';
321 $self->goalEndDate = $array['goalEndDate'] ?? '';
322 $self->designId = isset($array['designId']) ? sanitize_html_class($array['designId']) : null;
323 $self->inheritCampaignColors = $array['inheritCampaignColors'] ?? false;
324 $self->primaryColor = $array['primaryColor'] ?? '#2d802f';
325 $self->secondaryColor = $array['secondaryColor'] ?? '#f49420';
326 $self->goalAmount = $array['goalAmount'] ?? 0;
327 $self->registrationNotification = $array['registrationNotification'] ?? false;
328 $self->customCss = wp_strip_all_tags($array['customCss'] ?? '');
329 $self->pageSlug = $array['pageSlug'] ?? '';
330 $self->goalAchievedMessage = $array['goalAchievedMessage'] ?? __(
331 'Thank you to all our donors, we have met our fundraising goal.',
332 'give'
333 );
334 $self->receiptHeading = $array['receiptHeading'] ?? __(
335 'Hey {first_name}, thanks for your donation!',
336 'give'
337 );
338 $self->receiptDescription = $array['receiptDescription'] ?? __(
339 '{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}.',
340 'give'
341 );
342
343 $self->enableReceiptConfirmationPage = $array['enableReceiptConfirmationPage'] ?? false;
344
345 $self->formStatus = ! empty($array['formStatus']) ? new DonationFormStatus(
346 $array['formStatus']
347 ) : DonationFormStatus::DRAFT();
348
349 $self->formGridCustomize = $array['formGridCustomize'] ?? false;
350 $self->formGridRedirectUrl = $array['formGridRedirectUrl'] ?? '';
351 $self->formGridDonateButtonText = $array['formGridDonateButtonText'] ?? '';
352 $self->formGridHideDocumentationLink = $array['formGridHideDocumentationLink'] ?? false;
353
354 $self->emailTemplateOptions = $array['emailTemplateOptions'] ?? [];
355
356 $self->emailOptionsStatus = $array['emailOptionsStatus'] ?? 'global';
357
358 $self->emailTemplate = $array['emailTemplate'] ?? 'default';
359
360 $self->emailFromName = $array['emailFromName'] ?? '';
361
362 $self->emailFromEmail = $array['emailFromEmail'] ?? '';
363
364 $self->emailLogo = $array['emailLogo'] ?? '';
365
366 $self->offlineDonationsCustomize = $array['offlineDonationsCustomize'] ?? false;
367
368 $self->offlineDonationsInstructions = $array['offlineDonationsInstructions'] ?? '';
369
370 $self->multiStepFirstButtonText = $array['multiStepFirstButtonText'] ?? __('Donate now', 'give');
371
372 $self->multiStepNextButtonText = $array['multiStepNextButtonText'] ?? __('Continue', 'give');
373
374 $self->pdfSettings = isset($array['pdfSettings']) && is_array(
375 $array['pdfSettings']
376 ) ? $array['pdfSettings'] : [];
377
378 $self->designSettingsImageUrl = $array['designSettingsImageUrl'] ?? '';
379 $self->designSettingsImageAlt = $array['designSettingsImageAlt'] ?? $self->formTitle;
380 $self->designSettingsImageStyle = ! empty($array['designSettingsImageStyle']) ? new DesignSettingsImageStyle(
381 $array['designSettingsImageStyle']
382 ) : DesignSettingsImageStyle::BACKGROUND();
383
384 $self->designSettingsLogoUrl = $array['designSettingsLogoUrl'] ?? '';
385 $self->designSettingsLogoPosition = ! empty($array['designSettingsLogoPosition']) ? new DesignSettingsLogoPosition(
386 $array['designSettingsLogoPosition']
387 ) : DesignSettingsLogoPosition::LEFT();
388
389 $self->designSettingsSectionStyle = ! empty($array['designSettingsSectionStyle']) ? new DesignSettingsSectionStyle(
390 $array['designSettingsSectionStyle']
391 ) : DesignSettingsSectionStyle::DEFAULT();
392
393 $self->designSettingsTextFieldStyle = ! empty($array['designSettingsTextFieldStyle']) ? new DesignSettingsTextFieldStyle(
394 $array['designSettingsTextFieldStyle']
395 ) : DesignSettingsTextFieldStyle::DEFAULT();
396
397 $self->designSettingsImageColor = $array['designSettingsImageColor'] ?? '';
398
399 $self->designSettingsImageOpacity = $array['designSettingsImageOpacity'] ?? '';
400
401 $self->formExcerpt = $array['formExcerpt'] ?? '';
402
403 $self->currencySwitcherSettings = isset($array['currencySwitcherSettings']) && is_array(
404 $array['currencySwitcherSettings']
405 ) ? $array['currencySwitcherSettings'] : [];
406
407 return $self;
408 }
409
410 /**
411 * @since 3.0.0
412 */
413 public static function fromJson(string $json): self
414 {
415 return self::fromArray(
416 json_decode($json, true)
417 );
418 }
419
420 /**
421 * @since 3.0.0
422 */
423 public function toArray(): array
424 {
425 return get_object_vars($this);
426 }
427
428 /**
429 * @since 4.1.0 Add goalSource
430 * @since 3.2.0 Remove call to addSlashesRecursive method for emailTemplateOptions in favor of SanitizeDonationFormPreviewRequest class
431 * @since 3.0.0
432 */
433 public function toJson($options = 0): string
434 {
435 return json_encode(
436 array_merge(
437 $this->toArray(),
438 [
439 'goalSource' => $this->goalSource ? $this->goalSource->getValue() : GoalSource::FORM()->getValue(),
440 'goalType' => $this->goalType ? $this->goalType->getValue() : null,
441 ]
442 )
443 );
444 }
445 }
446