PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.0.4
GiveWP – Donation Plugin and Fundraising Platform v3.0.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
295 lines
1 <?php
2
3 namespace Give\DonationForms\Properties;
4
5 use Give\DonationForms\FormDesigns\ClassicFormDesign\ClassicFormDesign;
6 use Give\DonationForms\ValueObjects\DonationFormStatus;
7 use Give\DonationForms\ValueObjects\GoalType;
8 use Give\Framework\Support\Contracts\Arrayable;
9 use Give\Framework\Support\Contracts\Jsonable;
10
11 class FormSettings implements Arrayable, Jsonable
12 {
13 /**
14 * @var boolean
15 */
16 public $showHeader;
17 /**
18 * @var boolean
19 */
20 public $showHeading;
21 /**
22 * @var boolean
23 */
24 public $showDescription;
25 /**
26 * @var string
27 */
28 public $formTitle;
29 /**
30 * @var boolean
31 */
32 public $enableDonationGoal;
33 /**
34 * @var boolean
35 */
36 public $enableAutoClose;
37 /**
38 * @var GoalType
39 */
40 public $goalType;
41 /**
42 * @var string
43 */
44 public $designId;
45 /**
46 * @var string
47 */
48 public $heading;
49 /**
50 * @var string
51 */
52 public $description;
53 /**
54 * @var string
55 */
56 public $primaryColor;
57 /**
58 * @var string
59 */
60 public $secondaryColor;
61 /**
62 * @var float
63 */
64 public $goalAmount;
65 /**
66 * @var string
67 */
68 public $registration;
69 /**
70 * @var string
71 */
72 public $customCss;
73 /**
74 * @var string
75 */
76 public $goalAchievedMessage;
77
78 /**
79 * @var string
80 */
81 public $pageSlug;
82
83 /**
84 * @var string
85 */
86 public $receiptHeading;
87
88 /**
89 * @var string
90 */
91 public $receiptDescription;
92
93 /**
94 * @var DonationFormStatus
95 */
96 public $formStatus;
97
98 /**
99 * @var array
100 */
101 public $emailTemplateOptions;
102
103 /**
104 * @var string
105 * @todo Extract to a value object.
106 */
107 public $emailOptionsStatus;
108
109 /**
110 * @var string
111 */
112 public $emailTemplate;
113
114 /**
115 * @var string
116 */
117 public $emailLogo;
118
119 /**
120 * @var string
121 */
122 public $emailFromName;
123
124 /**
125 * @var string
126 */
127 public $emailFromEmail;
128
129 /**
130 * @var boolean
131 */
132 public $formGridCustomize;
133
134 /**
135 * @var string
136 */
137 public $formGridRedirectUrl;
138
139 /**
140 * @var string
141 */
142 public $formGridDonateButtonText;
143
144 /**
145 * @var boolean
146 */
147 public $formGridHideDocumentationLink;
148
149 /**
150 * @var boolean
151 */
152 public $offlineDonationsCustomize;
153
154 /**
155 * @var string
156 */
157 public $offlineDonationsInstructions;
158
159 /**
160 * @var string
161 */
162 public $donateButtonCaption;
163 /**
164 * @var string
165 */
166 public $multiStepFirstButtonText;
167 /**
168 * @var string
169 */
170 public $multiStepNextButtonText;
171
172 /**
173 * @var array
174 */
175 public $pdfSettings;
176
177 /**
178 * @since 3.0.0
179 */
180 public static function fromArray(array $array): self
181 {
182 $self = new self();
183
184 $self->showHeader = $array['showHeader'] ?? true;
185 $self->showHeading = $array['showHeading'] ?? true;
186 $self->heading = $array['heading'] ?? __('Support Our Cause', 'give');
187 $self->showDescription = $array['showDescription'] ?? true;
188 $self->description = $array['description'] ?? __(
189 'Help our organization by donating today! Donations go to making a difference for our cause.',
190 'give'
191 );
192 $self->formTitle = $array['formTitle'] ?? __('Donation Form', 'give');
193 $self->donateButtonCaption = $array['donateButtonCaption'] ?? __('Donate now', 'give');
194 $self->enableDonationGoal = $array['enableDonationGoal'] ?? false;
195 $self->enableAutoClose = $array['enableAutoClose'] ?? false;
196 $self->goalType = !empty($array['goalType']) && GoalType::isValid($array['goalType']) ? new GoalType(
197 $array['goalType']
198 ) : GoalType::AMOUNT();
199 $self->designId = $array['designId'] ?? null;
200 $self->primaryColor = $array['primaryColor'] ?? '#69b86b';
201 $self->secondaryColor = $array['secondaryColor'] ?? '#f49420';
202 $self->goalAmount = $array['goalAmount'] ?? 0;
203 $self->registration = $array['registration'] ?? 'none';
204 $self->customCss = $array['customCss'] ?? '';
205 $self->pageSlug = $array['pageSlug'] ?? '';
206 $self->goalAchievedMessage = $array['goalAchievedMessage'] ?? __(
207 'Thank you to all our donors, we have met our fundraising goal.',
208 'give'
209 );
210 $self->receiptHeading = $array['receiptHeading'] ?? __(
211 'Hey {first_name}, thanks for your donation!',
212 'give'
213 );
214 $self->receiptDescription = $array['receiptDescription'] ?? __(
215 '{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}.',
216 'give'
217 );
218 $self->formStatus = !empty($array['formStatus']) ? new DonationFormStatus(
219 $array['formStatus']
220 ) : DonationFormStatus::DRAFT();
221
222 $self->formGridCustomize = $array['formGridCustomize'] ?? false;
223 $self->formGridRedirectUrl = $array['formGridRedirectUrl'] ?? '';
224 $self->formGridDonateButtonText = $array['formGridDonateButtonText'] ?? '';
225 $self->formGridHideDocumentationLink = $array['formGridHideDocumentationLink'] ?? false;
226
227 $self->emailTemplateOptions = $array['emailTemplateOptions'] ?? [];
228
229 $self->emailOptionsStatus = $array['emailOptionsStatus'] ?? 'global';
230
231 $self->emailTemplate = $array['emailTemplate'] ?? 'default';
232
233 $self->emailFromName = $array['emailFromName'] ?? '';
234
235 $self->emailFromEmail = $array['emailFromEmail'] ?? '';
236
237 $self->emailLogo = $array['emailLogo'] ?? '';
238
239 $self->offlineDonationsCustomize = $array['offlineDonationsCustomize'] ?? false;
240
241 $self->offlineDonationsInstructions = $array['offlineDonationsInstructions'] ?? '';
242
243 $self->multiStepFirstButtonText = $array['multiStepFirstButtonText'] ?? __('Donate now', 'give');
244
245 $self->multiStepNextButtonText = $array['multiStepNextButtonText'] ?? __('Continue', 'give');
246
247 $self->pdfSettings = isset($array['pdfSettings']) && is_array(
248 $array['pdfSettings']
249 ) ? $array['pdfSettings'] : [];
250
251 return $self;
252 }
253
254 /**
255 * @since 3.0.0
256 */
257 public static function fromJson(string $json): self
258 {
259 return self::fromArray(
260 json_decode($json, true)
261 );
262 }
263
264 /**
265 * @since 3.0.0
266 */
267 public function toArray(): array
268 {
269 return get_object_vars($this);
270 }
271
272 /**
273 * @since 3.0.0
274 */
275 public function toJson($options = 0): string
276 {
277 return json_encode(
278 array_merge(
279 $this->toArray(),
280 [
281 'goalType' => $this->goalType ? $this->goalType->getValue() : null,
282 'emailTemplateOptions' => array_map([$this, 'addSlashesRecursive'], $this->emailTemplateOptions),
283 ]
284 )
285 );
286 }
287
288 public function addSlashesRecursive($value)
289 {
290 return is_array($value)
291 ? array_map([$this, 'addSlashesRecursive'], $value)
292 : addslashes($value);
293 }
294 }
295