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