PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.5.1
GiveWP – Donation Plugin and Fundraising Platform v3.5.1
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
351 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.4.0
193 * @var string
194 */
195 public $designSettingsImageStyle;
196
197 /**
198 * @since 3.4.0
199 * @var string
200 */
201 public $designSettingsLogoUrl;
202
203 /**
204 * @since 3.4.0
205 * @var string
206 */
207 public $designSettingsLogoPosition;
208
209 /**
210 * @since 3.4.0
211 * @var string
212 */
213 public $designSettingsSectionStyle;
214
215 /**
216 * @since 3.4.0
217 * @var string
218 */
219 public $designSettingsTextFieldStyle;
220
221 /**
222 * @since 3.2.0 Added registrationNotification
223 * @since 3.0.0
224 */
225 public static function fromArray(array $array): self
226 {
227 $self = new self();
228
229 $self->showHeader = $array['showHeader'] ?? true;
230 $self->showHeading = $array['showHeading'] ?? true;
231 $self->heading = $array['heading'] ?? __('Support Our Cause', 'give');
232 $self->showDescription = $array['showDescription'] ?? true;
233 $self->description = $array['description'] ?? __(
234 'Help our organization by donating today! Donations go to making a difference for our cause.',
235 'give'
236 );
237 $self->formTitle = $array['formTitle'] ?? __('Donation Form', 'give');
238 $self->donateButtonCaption = $array['donateButtonCaption'] ?? __('Donate now', 'give');
239 $self->enableDonationGoal = $array['enableDonationGoal'] ?? false;
240 $self->enableAutoClose = $array['enableAutoClose'] ?? false;
241 $self->goalType = ! empty($array['goalType']) && GoalType::isValid($array['goalType']) ? new GoalType(
242 $array['goalType']
243 ) : GoalType::AMOUNT();
244 $self->designId = $array['designId'] ?? null;
245 $self->primaryColor = $array['primaryColor'] ?? '#69b86b';
246 $self->secondaryColor = $array['secondaryColor'] ?? '#f49420';
247 $self->goalAmount = $array['goalAmount'] ?? 0;
248 $self->registrationNotification = $array['registrationNotification'] ?? false;
249 $self->customCss = $array['customCss'] ?? '';
250 $self->pageSlug = $array['pageSlug'] ?? '';
251 $self->goalAchievedMessage = $array['goalAchievedMessage'] ?? __(
252 'Thank you to all our donors, we have met our fundraising goal.',
253 'give'
254 );
255 $self->receiptHeading = $array['receiptHeading'] ?? __(
256 'Hey {first_name}, thanks for your donation!',
257 'give'
258 );
259 $self->receiptDescription = $array['receiptDescription'] ?? __(
260 '{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}.',
261 'give'
262 );
263 $self->formStatus = ! empty($array['formStatus']) ? new DonationFormStatus(
264 $array['formStatus']
265 ) : DonationFormStatus::DRAFT();
266
267 $self->formGridCustomize = $array['formGridCustomize'] ?? false;
268 $self->formGridRedirectUrl = $array['formGridRedirectUrl'] ?? '';
269 $self->formGridDonateButtonText = $array['formGridDonateButtonText'] ?? '';
270 $self->formGridHideDocumentationLink = $array['formGridHideDocumentationLink'] ?? false;
271
272 $self->emailTemplateOptions = $array['emailTemplateOptions'] ?? [];
273
274 $self->emailOptionsStatus = $array['emailOptionsStatus'] ?? 'global';
275
276 $self->emailTemplate = $array['emailTemplate'] ?? 'default';
277
278 $self->emailFromName = $array['emailFromName'] ?? '';
279
280 $self->emailFromEmail = $array['emailFromEmail'] ?? '';
281
282 $self->emailLogo = $array['emailLogo'] ?? '';
283
284 $self->offlineDonationsCustomize = $array['offlineDonationsCustomize'] ?? false;
285
286 $self->offlineDonationsInstructions = $array['offlineDonationsInstructions'] ?? '';
287
288 $self->multiStepFirstButtonText = $array['multiStepFirstButtonText'] ?? __('Donate now', 'give');
289
290 $self->multiStepNextButtonText = $array['multiStepNextButtonText'] ?? __('Continue', 'give');
291
292 $self->pdfSettings = isset($array['pdfSettings']) && is_array(
293 $array['pdfSettings']
294 ) ? $array['pdfSettings'] : [];
295
296 $self->designSettingsImageUrl = $array['designSettingsImageUrl'] ?? '';
297 $self->designSettingsImageStyle = ! empty($array['designSettingsImageStyle']) ? new DesignSettingsImageStyle(
298 $array['designSettingsImageStyle']
299 ) : DesignSettingsImageStyle::BACKGROUND();
300
301 $self->designSettingsLogoUrl = $array['designSettingsLogoUrl'] ?? '';
302 $self->designSettingsLogoPosition = ! empty($array['designSettingsLogoPosition']) ? new DesignSettingsLogoPosition(
303 $array['designSettingsLogoPosition']
304 ) : DesignSettingsLogoPosition::LEFT();
305
306 $self->designSettingsSectionStyle = ! empty($array['designSettingsSectionStyle']) ? new DesignSettingsSectionStyle(
307 $array['designSettingsSectionStyle']
308 ) : DesignSettingsSectionStyle::DEFAULT();
309
310 $self->designSettingsTextFieldStyle = ! empty($array['designSettingsTextFieldStyle']) ? new DesignSettingsTextFieldStyle(
311 $array['designSettingsTextFieldStyle']
312 ) : DesignSettingsTextFieldStyle::DEFAULT();
313
314 return $self;
315 }
316
317 /**
318 * @since 3.0.0
319 */
320 public static function fromJson(string $json): self
321 {
322 return self::fromArray(
323 json_decode($json, true)
324 );
325 }
326
327 /**
328 * @since 3.0.0
329 */
330 public function toArray(): array
331 {
332 return get_object_vars($this);
333 }
334
335 /**
336 * @since 3.2.0 Remove call to addSlashesRecursive method for emailTemplateOptions in favor of SanitizeDonationFormPreviewRequest class
337 * @since 3.0.0
338 */
339 public function toJson($options = 0): string
340 {
341 return json_encode(
342 array_merge(
343 $this->toArray(),
344 [
345 'goalType' => $this->goalType ? $this->goalType->getValue() : null,
346 ]
347 )
348 );
349 }
350 }
351