PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 4.14.2
GiveWP – Donation Plugin and Fundraising Platform v4.14.2
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 1 year ago GoalSettings.php 11 months ago
FormSettings.php
445 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.1.0 Added $inheritCampaignColors
288 * @since 3.16.0 Added $enableReceiptConfirmationPage
289 * @since 3.7.0 Added formExcerpt
290 * @since 3.11.0 Sanitize customCSS property
291 * @since 3.2.0 Added registrationNotification
292 * @since 3.0.0
293 */
294 public static function fromArray(array $array): self
295 {
296 $self = new self();
297
298 $self->showHeader = $array['showHeader'] ?? true;
299 $self->showHeading = $array['showHeading'] ?? true;
300 $self->heading = $array['heading'] ?? __('Support Our Cause', 'give');
301 $self->showDescription = $array['showDescription'] ?? true;
302 $self->description = $array['description'] ?? __(
303 'Help our organization by donating today! Donations go to making a difference for our cause.',
304 'give'
305 );
306 $self->formTitle = $array['formTitle'] ?? __('Donation Form', 'give');
307 $self->donateButtonCaption = $array['donateButtonCaption'] ?? __('Donate now', 'give');
308 $self->enableDonationGoal = $array['enableDonationGoal'] ?? false;
309 $self->enableAutoClose = $array['enableAutoClose'] ?? false;
310 $self->goalSource = ! empty($array['goalSource']) && GoalSource::isValid($array['goalSource'])
311 ? new GoalSource($array['goalSource'])
312 : GoalSource::FORM();
313 $self->goalType = ! empty($array['goalType']) && GoalType::isValid($array['goalType']) ? new GoalType(
314 $array['goalType']
315 ) : GoalType::AMOUNT();
316 $self->goalProgressType = ! empty($array['goalProgressType']) && GoalProgressType::isValid($array['goalProgressType'])
317 ? new GoalProgressType($array['goalProgressType'])
318 : GoalProgressType::ALL_TIME();
319 $self->goalStartDate = $array['goalStartDate'] ?? '';
320 $self->goalEndDate = $array['goalEndDate'] ?? '';
321 $self->designId = $array['designId'] ?? null;
322 $self->inheritCampaignColors = $array['inheritCampaignColors'] ?? false;
323 $self->primaryColor = $array['primaryColor'] ?? '#2d802f';
324 $self->secondaryColor = $array['secondaryColor'] ?? '#f49420';
325 $self->goalAmount = $array['goalAmount'] ?? 0;
326 $self->registrationNotification = $array['registrationNotification'] ?? false;
327 $self->customCss = wp_strip_all_tags($array['customCss'] ?? '');
328 $self->pageSlug = $array['pageSlug'] ?? '';
329 $self->goalAchievedMessage = $array['goalAchievedMessage'] ?? __(
330 'Thank you to all our donors, we have met our fundraising goal.',
331 'give'
332 );
333 $self->receiptHeading = $array['receiptHeading'] ?? __(
334 'Hey {first_name}, thanks for your donation!',
335 'give'
336 );
337 $self->receiptDescription = $array['receiptDescription'] ?? __(
338 '{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}.',
339 'give'
340 );
341
342 $self->enableReceiptConfirmationPage = $array['enableReceiptConfirmationPage'] ?? false;
343
344 $self->formStatus = ! empty($array['formStatus']) ? new DonationFormStatus(
345 $array['formStatus']
346 ) : DonationFormStatus::DRAFT();
347
348 $self->formGridCustomize = $array['formGridCustomize'] ?? false;
349 $self->formGridRedirectUrl = $array['formGridRedirectUrl'] ?? '';
350 $self->formGridDonateButtonText = $array['formGridDonateButtonText'] ?? '';
351 $self->formGridHideDocumentationLink = $array['formGridHideDocumentationLink'] ?? false;
352
353 $self->emailTemplateOptions = $array['emailTemplateOptions'] ?? [];
354
355 $self->emailOptionsStatus = $array['emailOptionsStatus'] ?? 'global';
356
357 $self->emailTemplate = $array['emailTemplate'] ?? 'default';
358
359 $self->emailFromName = $array['emailFromName'] ?? '';
360
361 $self->emailFromEmail = $array['emailFromEmail'] ?? '';
362
363 $self->emailLogo = $array['emailLogo'] ?? '';
364
365 $self->offlineDonationsCustomize = $array['offlineDonationsCustomize'] ?? false;
366
367 $self->offlineDonationsInstructions = $array['offlineDonationsInstructions'] ?? '';
368
369 $self->multiStepFirstButtonText = $array['multiStepFirstButtonText'] ?? __('Donate now', 'give');
370
371 $self->multiStepNextButtonText = $array['multiStepNextButtonText'] ?? __('Continue', 'give');
372
373 $self->pdfSettings = isset($array['pdfSettings']) && is_array(
374 $array['pdfSettings']
375 ) ? $array['pdfSettings'] : [];
376
377 $self->designSettingsImageUrl = $array['designSettingsImageUrl'] ?? '';
378 $self->designSettingsImageAlt = $array['designSettingsImageAlt'] ?? $self->formTitle;
379 $self->designSettingsImageStyle = ! empty($array['designSettingsImageStyle']) ? new DesignSettingsImageStyle(
380 $array['designSettingsImageStyle']
381 ) : DesignSettingsImageStyle::BACKGROUND();
382
383 $self->designSettingsLogoUrl = $array['designSettingsLogoUrl'] ?? '';
384 $self->designSettingsLogoPosition = ! empty($array['designSettingsLogoPosition']) ? new DesignSettingsLogoPosition(
385 $array['designSettingsLogoPosition']
386 ) : DesignSettingsLogoPosition::LEFT();
387
388 $self->designSettingsSectionStyle = ! empty($array['designSettingsSectionStyle']) ? new DesignSettingsSectionStyle(
389 $array['designSettingsSectionStyle']
390 ) : DesignSettingsSectionStyle::DEFAULT();
391
392 $self->designSettingsTextFieldStyle = ! empty($array['designSettingsTextFieldStyle']) ? new DesignSettingsTextFieldStyle(
393 $array['designSettingsTextFieldStyle']
394 ) : DesignSettingsTextFieldStyle::DEFAULT();
395
396 $self->designSettingsImageColor = $array['designSettingsImageColor'] ?? '';
397
398 $self->designSettingsImageOpacity = $array['designSettingsImageOpacity'] ?? '';
399
400 $self->formExcerpt = $array['formExcerpt'] ?? '';
401
402 $self->currencySwitcherSettings = isset($array['currencySwitcherSettings']) && is_array(
403 $array['currencySwitcherSettings']
404 ) ? $array['currencySwitcherSettings'] : [];
405
406 return $self;
407 }
408
409 /**
410 * @since 3.0.0
411 */
412 public static function fromJson(string $json): self
413 {
414 return self::fromArray(
415 json_decode($json, true)
416 );
417 }
418
419 /**
420 * @since 3.0.0
421 */
422 public function toArray(): array
423 {
424 return get_object_vars($this);
425 }
426
427 /**
428 * @since 4.1.0 Add goalSource
429 * @since 3.2.0 Remove call to addSlashesRecursive method for emailTemplateOptions in favor of SanitizeDonationFormPreviewRequest class
430 * @since 3.0.0
431 */
432 public function toJson($options = 0): string
433 {
434 return json_encode(
435 array_merge(
436 $this->toArray(),
437 [
438 'goalSource' => $this->goalSource ? $this->goalSource->getValue() : GoalSource::FORM()->getValue(),
439 'goalType' => $this->goalType ? $this->goalType->getValue() : null,
440 ]
441 )
442 );
443 }
444 }
445