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