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