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