PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.18.0
GiveWP – Donation Plugin and Fundraising Platform v2.18.0
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 / includes / admin / forms / class-metabox-form-data.php
give / includes / admin / forms Last commit date
class-give-form-duplicator.php 6 years ago class-metabox-form-data.php 4 years ago dashboard-columns.php 4 years ago metabox.php 6 years ago
class-metabox-form-data.php
1443 lines
1 <?php
2 /**
3 * Donation Form Data
4 *
5 * Displays the form data box, tabbed, with several panels.
6 *
7 * @package Give
8 * @subpackage Classes/Give_MetaBox_Form_Data
9 * @copyright Copyright (c) 2016, GiveWP
10 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11 * @since 1.8
12 */
13
14 use Give\Form\Template;
15 use Give\FormAPI\Fields;
16 use Give\FormAPI\Section;
17 use Give\Helpers\Form\Template as FormTemplateUtils;
18 use Give\Views\Admin\UpsellNotice;
19
20 /**
21 * Give_Meta_Box_Form_Data Class.
22 */
23 class Give_MetaBox_Form_Data {
24
25 /**
26 * Meta box settings.
27 *
28 * @since 1.8
29 * @var array
30 */
31 private $settings = [];
32
33 /**
34 * Metabox ID.
35 *
36 * @since 1.8
37 * @var string
38 */
39 private $metabox_id;
40
41 /**
42 * Metabox Label.
43 *
44 * @since 1.8
45 * @var string
46 */
47 private $metabox_label;
48
49
50 /**
51 * Give_MetaBox_Form_Data constructor.
52 */
53 function __construct() {
54 $this->metabox_id = 'give-metabox-form-data';
55 $this->metabox_label = __( 'Donation Form Options', 'give' );
56
57 // Setup.
58 add_action( 'admin_init', [ $this, 'setup' ] );
59
60 // Add metabox.
61 add_action( 'add_meta_boxes', [ $this, 'add_meta_box' ], 10 );
62
63 // Save form meta.
64 add_action( 'save_post_give_forms', [ $this, 'save' ], 10, 2 );
65
66 add_action( 'give_save__give_form_template', [ $this, 'save_form_template_settings' ], 10, 3 );
67
68 // cmb2 old setting loaders.
69 // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) );
70 // Add offline donations options.
71 add_filter( 'give_metabox_form_data_settings', [ $this, 'add_offline_donations_setting_tab' ], 0, 1 );
72
73 // Maintain active tab query parameter after save.
74 add_filter( 'redirect_post_location', [ $this, 'maintain_active_tab' ], 10, 2 );
75 }
76
77 /**
78 * Setup metabox related data.
79 *
80 * @since 1.8
81 *
82 * @return void
83 */
84 function setup() {
85 $this->settings = $this->get_settings();
86 }
87
88
89 /**
90 * Get metabox settings
91 *
92 * @since 1.8
93 *
94 * @return array
95 */
96 function get_settings() {
97 $post_id = give_get_admin_post_id();
98 $price_placeholder = give_format_decimal( '1.00', false, false );
99
100 // Start with an underscore to hide fields from custom fields list
101 $prefix = '_give_';
102
103 $settings = [
104 /**
105 * Theme Options
106 */
107 'form_template_options' => apply_filters(
108 'give_form_template_options',
109 [
110 'id' => 'form_template_options',
111 'title' => __( 'Form Template', 'give' ),
112 'icon-html' => '<i class="fas fa-palette"></i>',
113 'fields' => [
114 [
115 'id' => $prefix . 'form_template',
116 'name' => 'form_template',
117 'type' => 'hidden',
118 'default' => '',
119 ],
120 ],
121 ]
122 ),
123
124 /**
125 * Repeatable Field Groups
126 */
127 'form_field_options' => apply_filters(
128 'give_forms_field_options',
129 [
130 'id' => 'form_field_options',
131 'title' => __( 'Donation Options', 'give' ),
132 'icon-html' => '<i class="fas fa-heart"></i>',
133 'fields' => apply_filters(
134 'give_forms_donation_form_metabox_fields',
135 [
136 // Donation Option.
137 [
138 'name' => __( 'Donation Option', 'give' ),
139 'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ),
140 'id' => $prefix . 'price_option',
141 'type' => 'radio_inline',
142 'default' => 'multi',
143 'options' => apply_filters(
144 'give_forms_price_options',
145 [
146 'multi' => __( 'Multi-level Donation', 'give' ),
147 'set' => __( 'Set Donation', 'give' ),
148 ]
149 ),
150 ],
151 [
152 'name' => __( 'Set Donation', 'give' ),
153 'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ),
154 'id' => $prefix . 'set_price',
155 'default' => give_format_decimal( [ 'amount' => '25.00' ] ),
156 'type' => 'text_small',
157 'data_type' => 'price',
158 'attributes' => [
159 'placeholder' => $price_placeholder,
160 'class' => 'give-money-field',
161 ],
162 'wrapper_class' => 'give-hidden',
163 ],
164 // Custom Amount.
165 [
166 'name' => __( 'Custom Amount', 'give' ),
167 'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ),
168 'id' => $prefix . 'custom_amount',
169 'type' => 'radio_inline',
170 'default' => 'enabled',
171 'options' => [
172 'enabled' => __( 'Enabled', 'give' ),
173 'disabled' => __( 'Disabled', 'give' ),
174 ],
175 ],
176 [
177 'name' => __( 'Donation Limit', 'give' ),
178 'description' => __( 'Set the minimum and maximum amount for all gateways.', 'give' ),
179 'id' => $prefix . 'custom_amount_range',
180 'type' => 'donation_limit',
181 'wrapper_class' => 'give-hidden',
182 'data_type' => 'price',
183 'attributes' => [
184 'placeholder' => $price_placeholder,
185 'class' => 'give-money-field',
186 ],
187 'options' => [
188 'display_label' => __( 'Donation Limits: ', 'give' ),
189 'minimum' => give_format_decimal( [ 'amount' => '5.00' ] ),
190 'maximum' => give_format_decimal( [ 'amount' => '999999.99' ] ),
191 ],
192 ],
193 [
194 'name' => __( 'Custom Amount Text', 'give' ),
195 'description' => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as its own level (button, radio, or select option).', 'give' ),
196 'id' => $prefix . 'custom_amount_text',
197 'type' => 'text_medium',
198 'default' => __( 'Custom Amount', 'give' ),
199 'attributes' => [
200 'rows' => 3,
201 ],
202 'wrapper_class' => 'give-hidden',
203 ],
204 // Donation Levels.
205 [
206 'id' => $prefix . 'donation_levels',
207 'type' => 'group',
208 'options' => [
209 'add_button' => __( 'Add Level', 'give' ),
210 'header_title' => __( 'Donation Level', 'give' ),
211 'remove_button' => '<span class="dashicons dashicons-no"></span>',
212 ],
213 'default' => [
214 [
215 '_give_id' =>
216 [
217 'level_id' => 0,
218 ],
219 '_give_amount' => '10.000000',
220 ],
221 [
222 '_give_id' =>
223 [
224 'level_id' => 1,
225 ],
226 '_give_amount' => '25.000000',
227 ],
228 [
229 '_give_id' =>
230 [
231 'level_id' => 2,
232 ],
233 '_give_amount' => '50.000000',
234 ],
235 [
236 '_give_id' =>
237 [
238 'level_id' => 3,
239 ],
240 '_give_amount' => '100.000000',
241 '_give_default' => 'default',
242 ],
243 [
244 '_give_id' =>
245 [
246 'level_id' => 5,
247 ],
248 '_give_amount' => '250.000000',
249 ],
250 ],
251 'wrapper_class' => 'give-hidden',
252 // Fields array works the same, except id's only need to be unique for this group.
253 // Prefix is not needed.
254 'fields' => apply_filters(
255 'give_donation_levels_table_row',
256 [
257 [
258 'name' => __( 'ID', 'give' ),
259 'id' => $prefix . 'id',
260 'type' => 'levels_id',
261 ],
262 [
263 'name' => __( 'Amount', 'give' ),
264 'id' => $prefix . 'amount',
265 'type' => 'text_small',
266 'data_type' => 'price',
267 'attributes' => [
268 'placeholder' => $price_placeholder,
269 'class' => 'give-money-field',
270 ],
271 ],
272 [
273 'name' => __( 'Text', 'give' ),
274 'id' => $prefix . 'text',
275 'type' => 'text',
276 'attributes' => [
277 'placeholder' => __( 'Donation Level', 'give' ),
278 'class' => 'give-multilevel-text-field',
279 ],
280 ],
281 [
282 'name' => __( 'Default', 'give' ),
283 'id' => $prefix . 'default',
284 'type' => 'give_default_radio_inline',
285 ],
286 ]
287 ),
288 ],
289 [
290 'name' => 'donation_options_docs',
291 'type' => 'docs_link',
292 'url' => 'http://docs.givewp.com/form-donation-options',
293 'title' => __( 'Donation Options', 'give' ),
294 ],
295 ],
296 $post_id
297 ),
298 ]
299 ),
300
301 /**
302 * Display Options
303 */
304 'form_display_options' => apply_filters(
305 'give_form_display_options',
306 [
307 'id' => 'form_display_options',
308 'title' => __( 'Form Fields', 'give' ),
309 'icon-html' => '<i class="fas fa-stream"></i>',
310 'fields' => apply_filters(
311 'give_forms_display_options_metabox_fields',
312 [
313 [
314 'name' => __( 'Default Gateway', 'give' ),
315 'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under GiveWP > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ),
316 'id' => $prefix . 'default_gateway',
317 'type' => 'default_gateway',
318 ],
319 [
320 'name' => __( 'Name Title Prefix', 'give' ),
321 'desc' => __( 'Do you want to add a name title prefix dropdown field before the donor\'s first name field? This will display a dropdown with options such as Mrs, Miss, Ms, Sir, and Dr for donor to choose from.', 'give' ),
322 'id' => $prefix . 'name_title_prefix',
323 'type' => 'radio_inline',
324 'options' => [
325 'global' => __( 'Global Option', 'give' ),
326 'required' => __( 'Required', 'give' ),
327 'optional' => __( 'Optional', 'give' ),
328 'disabled' => __( 'Disabled', 'give' ),
329 ],
330 'default' => 'global',
331 ],
332 [
333 'name' => __( 'Title Prefixes', 'give' ),
334 'desc' => __( 'Add or remove salutations from the dropdown using the field above.', 'give' ),
335 'id' => $prefix . 'title_prefixes',
336 'type' => 'chosen',
337 'data_type' => 'multiselect',
338 'allow-custom-values' => true,
339 'style' => 'width: 100%',
340 'wrapper_class' => 'give-hidden give-title-prefixes-wrap',
341 'options' => give_get_default_title_prefixes(),
342 ],
343 [
344 'name' => __( 'Company Donations', 'give' ),
345 'desc' => __( 'Do you want a Company field to appear after First Name and Last Name?', 'give' ),
346 'id' => $prefix . 'company_field',
347 'type' => 'radio_inline',
348 'default' => 'global',
349 'options' => [
350 'global' => __( 'Global Option', 'give' ),
351 'required' => __( 'Required', 'give' ),
352 'optional' => __( 'Optional', 'give' ),
353 'disabled' => __( 'Disabled', 'give' ),
354
355 ],
356 ],
357 [
358 'name' => __( 'Last Name Field Required', 'give' ),
359 'desc' => __( 'Do you want to force the Last Name field to be required?', 'give' ),
360 'id' => $prefix . 'last_name_field_required',
361 'type' => 'radio_inline',
362 'default' => 'global',
363 'options' => [
364 'global' => __( 'Global Option', 'give' ),
365 'required' => __( 'Required', 'give' ),
366 'optional' => __( 'Optional', 'give' ),
367 ],
368 ],
369 [
370 'name' => __( 'Anonymous Donations', 'give' ),
371 'desc' => __( 'Do you want to provide donors the ability mark themselves anonymous while giving? This will prevent their information from appearing publicly on your website but you will still receive their information for your records in the admin panel.', 'give' ),
372 'id' => "{$prefix}anonymous_donation",
373 'type' => 'radio_inline',
374 'default' => 'global',
375 'options' => [
376 'global' => __( 'Global Option', 'give' ),
377 'enabled' => __( 'Enabled', 'give' ),
378 'disabled' => __( 'Disabled', 'give' ),
379 ],
380 ],
381 [
382 'name' => __( 'Donor Comments', 'give' ),
383 'desc' => __( 'Do you want to provide donors the ability to add a comment to their donation? The comment will display publicly on the donor wall if they do not select to give anonymously.', 'give' ),
384 'id' => "{$prefix}donor_comment",
385 'type' => 'radio_inline',
386 'default' => 'global',
387 'options' => [
388 'global' => __( 'Global Option', 'give' ),
389 'enabled' => __( 'Enabled', 'give' ),
390 'disabled' => __( 'Disabled', 'give' ),
391 ],
392 ],
393 [
394 'name' => __( 'Guest Donations', 'give' ),
395 'desc' => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ),
396 'id' => $prefix . 'logged_in_only',
397 'type' => 'radio_inline',
398 'default' => 'enabled',
399 'options' => [
400 'enabled' => __( 'Enabled', 'give' ),
401 'disabled' => __( 'Disabled', 'give' ),
402 ],
403 ],
404 [
405 'name' => __( 'Registration', 'give' ),
406 'desc' => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ),
407 'id' => $prefix . 'show_register_form',
408 'type' => 'radio',
409 'options' => [
410 'none' => __( 'None', 'give' ),
411 'registration' => __( 'Registration', 'give' ),
412 'login' => __( 'Login', 'give' ),
413 'both' => __( 'Registration + Login', 'give' ),
414 ],
415 'default' => 'none',
416 ],
417 [
418 'name' => 'form_display_docs',
419 'type' => 'docs_link',
420 'url' => 'http://docs.givewp.com/form-display-options',
421 'title' => __( 'Form Display', 'give' ),
422 ],
423 ],
424 $post_id
425 ),
426 ]
427 ),
428
429 /**
430 * Donation Goals
431 */
432 'donation_goal_options' => apply_filters(
433 'give_donation_goal_options',
434 [
435 'id' => 'donation_goal_options',
436 'title' => __( 'Donation Goal', 'give' ),
437 'icon-html' => '<i class="fas fa-bullseye"></i>',
438 'fields' => apply_filters(
439 'give_forms_donation_goal_metabox_fields',
440 [
441 // Goals
442 [
443 'name' => __( 'Donation Goal', 'give' ),
444 'description' => __( 'Do you want to set a donation goal for this form?', 'give' ),
445 'id' => $prefix . 'goal_option',
446 'type' => 'radio_inline',
447 'default' => 'disabled',
448 'options' => [
449 'enabled' => __( 'Enabled', 'give' ),
450 'disabled' => __( 'Disabled', 'give' ),
451 ],
452 ],
453
454 [
455 'name' => __( 'Goal Format', 'give' ),
456 'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded" or "1 of 5 donations". You can also display a donor-based goal, such as "100 of 1,000 donors have given".', 'give' ),
457 'id' => $prefix . 'goal_format',
458 'type' => 'donation_form_goal',
459 'default' => 'amount',
460 'options' => [
461 'amount' => __( 'Amount Raised', 'give' ),
462 'percentage' => __( 'Percentage Raised', 'give' ),
463 'donation' => __( 'Number of Donations', 'give' ),
464 'donors' => __( 'Number of Donors', 'give' ),
465 ],
466 ],
467
468 [
469 'name' => __( 'Goal Amount', 'give' ),
470 'description' => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ),
471 'id' => $prefix . 'set_goal',
472 'type' => 'text_small',
473 'data_type' => 'price',
474 'default' => give_format_decimal( [ 'amount' => '10000.00' ] ),
475 'attributes' => [
476 'placeholder' => give_format_decimal( [ 'amount' => '10000.00' ] ),
477 'class' => 'give-money-field',
478 ],
479 'wrapper_class' => 'give-hidden',
480 ],
481 [
482 'id' => $prefix . 'number_of_donation_goal',
483 'name' => __( 'Donation Goal', 'give' ),
484 'desc' => __( 'Set the total number of donations as a goal.', 'give' ),
485 'type' => 'number',
486 'default' => 1,
487 'attributes' => [
488 'placeholder' => 1,
489 ],
490 ],
491 [
492 'id' => $prefix . 'number_of_donor_goal',
493 'name' => __( 'Donor Goal', 'give' ),
494 'desc' => __( 'Set the total number of donors as a goal.', 'give' ),
495 'type' => 'number',
496 'default' => 1,
497 'attributes' => [
498 'placeholder' => 1,
499 ],
500 ],
501 [
502 'name' => __( 'Progress Bar Color', 'give' ),
503 'desc' => __( 'Customize the color of the goal progress bar.', 'give' ),
504 'id' => $prefix . 'goal_color',
505 'type' => 'colorpicker',
506 'default' => '#2bc253',
507 'wrapper_class' => 'give-hidden',
508 ],
509
510 [
511 'name' => __( 'Close Form', 'give' ),
512 'desc' => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ),
513 'id' => $prefix . 'close_form_when_goal_achieved',
514 'type' => 'radio_inline',
515 'default' => 'disabled',
516 'options' => [
517 'enabled' => __( 'Enabled', 'give' ),
518 'disabled' => __( 'Disabled', 'give' ),
519 ],
520 'wrapper_class' => 'give-hidden',
521 ],
522 [
523 'name' => __( 'Goal Achieved Message', 'give' ),
524 'desc' => __( 'Do you want to display a custom message when the goal is closed?', 'give' ),
525 'id' => $prefix . 'form_goal_achieved_message',
526 'type' => 'wysiwyg',
527 'default' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ),
528 'wrapper_class' => 'give-hidden',
529 ],
530 [
531 'name' => 'donation_goal_docs',
532 'type' => 'docs_link',
533 'url' => 'http://docs.givewp.com/form-donation-goal',
534 'title' => __( 'Donation Goal', 'give' ),
535 ],
536 ],
537 $post_id
538 ),
539 ]
540 ),
541
542 /**
543 * Terms & Conditions
544 */
545 'form_terms_options' => apply_filters(
546 'give_forms_terms_options',
547 [
548 'id' => 'form_terms_options',
549 'title' => __( 'Terms & Conditions', 'give' ),
550 'icon-html' => '<i class="far fa-check-square"></i>',
551 'fields' => apply_filters(
552 'give_forms_terms_options_metabox_fields',
553 [
554 // Donation Option
555 [
556 'name' => __( 'Terms and Conditions', 'give' ),
557 'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ),
558 'id' => $prefix . 'terms_option',
559 'type' => 'radio_inline',
560 'options' => apply_filters(
561 'give_forms_content_options_select',
562 [
563 'global' => __( 'Global Option', 'give' ),
564 'enabled' => __( 'Customize', 'give' ),
565 'disabled' => __( 'Disable', 'give' ),
566 ]
567 ),
568 'default' => 'global',
569 ],
570 [
571 'id' => $prefix . 'agree_label',
572 'name' => __( 'Agreement Label', 'give' ),
573 'desc' => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ),
574 'type' => 'textarea',
575 'attributes' => [
576 'placeholder' => __( 'Agree to Terms?', 'give' ),
577 'rows' => 1,
578 ],
579 'wrapper_class' => 'give-hidden',
580 ],
581 [
582 'id' => $prefix . 'agree_text',
583 'name' => __( 'Agreement Text', 'give' ),
584 'desc' => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ),
585 'default' => give_get_option( 'agreement_text' ),
586 'type' => 'wysiwyg',
587 'wrapper_class' => 'give-hidden',
588 ],
589 [
590 'name' => 'terms_docs',
591 'type' => 'docs_link',
592 'url' => 'http://docs.givewp.com/form-terms',
593 'title' => __( 'Terms and Conditions', 'give' ),
594 ],
595 ],
596 $post_id
597 ),
598 ]
599 ),
600 ];
601
602 /**
603 * Filter the metabox tabbed panel settings.
604 */
605 $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id );
606
607 // Output.
608 return $settings;
609 }
610
611 /**
612 * Add metabox.
613 *
614 * @since 1.8
615 *
616 * @return void
617 */
618 public function add_meta_box() {
619 add_meta_box(
620 $this->get_metabox_ID(),
621 $this->get_metabox_label(),
622 [ $this, 'output' ],
623 [ 'give_forms' ],
624 'normal',
625 'high'
626 );
627
628 // Show Goal Metabox only if goal is enabled.
629 if ( give_is_setting_enabled( give_get_meta( give_get_admin_post_id(), '_give_goal_option', true ) ) ) {
630 add_meta_box(
631 'give-form-goal-stats',
632 __( 'Goal Statistics', 'give' ),
633 [ $this, 'output_goal' ],
634 [ 'give_forms' ],
635 'side',
636 'low'
637 );
638 }
639
640 }
641
642
643 /**
644 * Enqueue scripts.
645 *
646 * @since 1.8
647 *
648 * @return void
649 */
650 function enqueue_script() {
651 global $post;
652
653 if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
654
655 }
656 }
657
658 /**
659 * Get metabox id.
660 *
661 * @since 1.8
662 *
663 * @return string
664 */
665 function get_metabox_ID() {
666 return $this->metabox_id;
667 }
668
669 /**
670 * Get metabox label.
671 *
672 * @since 1.8
673 *
674 * @return string
675 */
676 function get_metabox_label() {
677 return $this->metabox_label;
678 }
679
680
681 /**
682 * Get metabox tabs.
683 *
684 * @since 1.8
685 *
686 * @return array
687 */
688 public function get_tabs() {
689 $tabs = [];
690
691 if ( ! empty( $this->settings ) ) {
692 foreach ( $this->settings as $setting ) {
693 if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) {
694 continue;
695 }
696 $tab = [
697 'id' => $setting['id'],
698 'label' => $setting['title'],
699 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ),
700 ];
701
702 if ( $this->has_sub_tab( $setting ) ) {
703 if ( empty( $setting['sub-fields'] ) ) {
704 $tab = [];
705 } else {
706 foreach ( $setting['sub-fields'] as $sub_fields ) {
707 $tab['sub-fields'][] = [
708 'id' => $sub_fields['id'],
709 'label' => $sub_fields['title'],
710 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ),
711 ];
712 }
713 }
714 }
715
716 if ( ! empty( $tab ) ) {
717 $tabs[] = $tab;
718 }
719 }
720 }
721
722 return $tabs;
723 }
724
725 /**
726 * Output metabox settings.
727 *
728 * @since 1.8
729 *
730 * @return void
731 */
732 public function output() {
733 // Bailout.
734 if ( $form_data_tabs = $this->get_tabs() ) :
735 Template\LegacyFormSettingCompatibility::migrateExistingFormSettings();
736
737 $active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_template_options';
738 wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' );
739
740 $added_upsells_notice = false;
741 ?>
742 <input id="give_form_active_tab" type="hidden" name="give_form_active_tab">
743 <div class="give-metabox-panel-wrap">
744 <ul class="give-form-data-tabs give-metabox-tabs">
745 <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?>
746 <?php
747 // Determine if current tab is active.
748 $is_active = $active_tab === $form_data_tab['id'] ? true : false;
749 ?>
750 <li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>">
751 <a href="#<?php echo $form_data_tab['id']; ?>"
752 data-tab-id="<?php echo $form_data_tab['id']; ?>">
753 <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?>
754 <?php echo $form_data_tab['icon-html']; ?>
755 <?php else : ?>
756 <i class="fas fa-angle-right"></i>
757 <?php endif; ?>
758 <span class="give-label"><?php echo $form_data_tab['label']; ?></span>
759 </a>
760 <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?>
761 <ul class="give-metabox-sub-tabs give-hidden">
762 <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?>
763 <li class="<?php echo "{$sub_tab['id']}_tab"; ?>">
764 <a href="#<?php echo $sub_tab['id']; ?>"
765 data-tab-id="<?php echo $sub_tab['id']; ?>">
766 <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?>
767 <?php echo $sub_tab['icon-html']; ?>
768 <?php else : ?>
769 <i class="fas fa-angle-right"></i>
770 <?php endif; ?>
771 <span class="give-label"><?php echo $sub_tab['label']; ?></span>
772 </a>
773 </li>
774 <?php endforeach; ?>
775 </ul>
776 <?php endif; ?>
777 </li>
778 <?php endforeach; ?>
779 </ul>
780
781 <?php foreach ( $this->settings as $setting ) : ?>
782 <?php do_action( "give_before_{$setting['id']}_settings" ); ?>
783 <?php
784 // Determine if current panel is active.
785 $is_active = $active_tab === $setting['id'];
786 ?>
787 <div id="<?php echo $setting['id']; ?>"
788 class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>">
789 <?php
790 if ( ! $added_upsells_notice ) {
791 echo UpsellNotice::recurringAddon();
792 $added_upsells_notice = true;
793 }
794 ?>
795 <?php if ( ! empty( $setting['fields'] ) ) : ?>
796 <?php foreach ( $setting['fields'] as $field ) : ?>
797 <?php give_render_field( $field ); ?>
798 <?php endforeach; ?>
799 <?php endif; ?>
800 <?php do_action( "give_post_{$setting['id']}_settings" ); ?>
801 </div>
802 <?php do_action( "give_after_{$setting['id']}_settings" ); ?>
803
804
805 <?php if ( $this->has_sub_tab( $setting ) ) : ?>
806 <?php if ( ! empty( $setting['sub-fields'] ) ) : ?>
807 <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?>
808 <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden">
809 <?php if ( ! empty( $sub_fields['fields'] ) ) : ?>
810 <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?>
811 <?php give_render_field( $sub_field ); ?>
812 <?php endforeach; ?>
813 <?php endif; ?>
814 </div>
815 <?php endforeach; ?>
816 <?php endif; ?>
817 <?php endif; ?>
818 <?php endforeach; ?>
819 </div>
820 <?php
821 endif; // End if().
822 }
823
824 /**
825 * Output Goal meta-box settings.
826 *
827 * @param object $post Post Object.
828 *
829 * @access public
830 * @since 2.1.0
831 *
832 * @return void
833 */
834 public function output_goal( $post ) {
835
836 echo give_admin_form_goal_stats( $post->ID );
837
838 }
839
840 /**
841 * Check if setting field has sub tabs/fields
842 *
843 * @param array $field_setting Field Settings.
844 *
845 * @since 1.8
846 *
847 * @return bool
848 */
849 private function has_sub_tab( $field_setting ) {
850 $has_sub_tab = false;
851 if ( array_key_exists( 'sub-fields', $field_setting ) ) {
852 $has_sub_tab = true;
853 }
854
855 return $has_sub_tab;
856 }
857
858 /**
859 * CMB2 settings loader.
860 *
861 * @since 1.8
862 *
863 * @return array
864 */
865 function cmb2_metabox_settings() {
866 $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', [] );
867 $give_forms_settings = $all_cmb2_settings;
868
869 // Filter settings: Use only give forms related settings.
870 foreach ( $all_cmb2_settings as $index => $setting ) {
871 if ( ! in_array( 'give_forms', $setting['object_types'] ) ) {
872 unset( $give_forms_settings[ $index ] );
873 }
874 }
875
876 return $give_forms_settings;
877
878 }
879
880 /**
881 * Check if we're saving, the trigger an action based on the post type.
882 *
883 * @param int $post_id Post ID.
884 * @param int|object $post Post Object.
885 *
886 * @since 1.8
887 *
888 * @return void
889 */
890 public function save( $post_id, $post ) {
891
892 // $post_id and $post are required.
893 if ( empty( $post_id ) || empty( $post ) ) {
894 return;
895 }
896
897 // Don't save meta boxes for revisions or autosaves.
898 if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
899 return;
900 }
901
902 // Check the nonce.
903 if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) {
904 return;
905 }
906
907 // Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
908 if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) {
909 return;
910 }
911
912 // Check user has permission to edit.
913 if ( ! current_user_can( 'edit_post', $post_id ) ) {
914 return;
915 }
916
917 // Fire action before saving form meta.
918 do_action( 'give_pre_process_give_forms_meta', $post_id, $post );
919
920 /**
921 * Filter the meta key to save.
922 * Third party addon developer can remove there meta keys from this array to handle saving data on there own.
923 */
924 $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() );
925
926 // Save form meta data.
927 if ( ! empty( $form_meta_keys ) ) {
928 foreach ( $form_meta_keys as $form_meta_key ) {
929
930 // Set default value for checkbox fields.
931 if (
932 ! isset( $_POST[ $form_meta_key ] ) &&
933 in_array( $this->get_field_type( $form_meta_key ), [ 'checkbox', 'chosen', 'multicheck' ] )
934 ) {
935 $_POST[ $form_meta_key ] = '';
936 }
937
938 if ( isset( $_POST[ $form_meta_key ] ) ) {
939 $setting_field = $this->get_setting_field( $form_meta_key );
940 if ( ! empty( $setting_field['type'] ) ) {
941 switch ( $setting_field['type'] ) {
942 case 'textarea':
943 case 'wysiwyg':
944 $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] );
945 break;
946
947 case 'donation_limit':
948 $form_meta_value = $_POST[ $form_meta_key ];
949 break;
950
951 case 'group':
952 $form_meta_value = [];
953
954 foreach ( $_POST[ $form_meta_key ] as $index => $group ) {
955
956 // Do not save template input field values.
957 if ( '{{row-count-placeholder}}' === $index ) {
958 continue;
959 }
960
961 $group_meta_value = [];
962 foreach ( $group as $field_id => $field_value ) {
963 switch ( $this->get_field_type( $field_id, $form_meta_key ) ) {
964 case 'wysiwyg':
965 $group_meta_value[ $field_id ] = wp_kses_post( $field_value );
966 break;
967
968 default:
969 $group_meta_value[ $field_id ] = give_clean( $field_value );
970 }
971 }
972
973 if ( ! empty( $group_meta_value ) ) {
974 $form_meta_value[ $index ] = $group_meta_value;
975 }
976 }
977
978 // Arrange repeater field keys in order.
979 $form_meta_value = array_values( $form_meta_value );
980 break;
981
982 default:
983 $form_meta_value = give_clean( $_POST[ $form_meta_key ] );
984 }// End switch().
985
986 /**
987 * Filter the form meta value before saving
988 *
989 * @since 1.8.9
990 */
991 $form_meta_value = apply_filters(
992 'give_pre_save_form_meta_value',
993 $this->sanitize_form_meta( $form_meta_value, $setting_field ),
994 $form_meta_key,
995 $this,
996 $post_id
997 );
998
999 // Range slider.
1000 if ( 'donation_limit' === $setting_field['type'] ) {
1001
1002 // Sanitize amount for db.
1003 $form_meta_value = array_map( 'give_sanitize_amount_for_db', $form_meta_value );
1004
1005 // Store it to form meta.
1006 give_update_meta( $post_id, $form_meta_key . '_minimum', $form_meta_value['minimum'] );
1007 give_update_meta( $post_id, $form_meta_key . '_maximum', $form_meta_value['maximum'] );
1008 } else {
1009 // Save data.
1010 give_update_meta( $post_id, $form_meta_key, $form_meta_value );
1011 }
1012
1013 // Verify and delete form meta based on the form status.
1014 give_set_form_closed_status( $post_id );
1015
1016 // Fire after saving form meta key.
1017 do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post );
1018 }// End if().
1019 }// End if().
1020 }// End foreach().
1021 }// End if().
1022
1023 // Update the goal progress for donation form.
1024 give_update_goal_progress( $post_id );
1025
1026 // Fire action after saving form meta.
1027 do_action( 'give_post_process_give_forms_meta', $post_id, $post );
1028 }
1029
1030
1031 /**
1032 * Save form template setting handler
1033 *
1034 * @param string $meta_key
1035 * @param string $new_template
1036 * @param int $formID
1037 */
1038 public function save_form_template_settings( $meta_key, $new_template, $formID ) {
1039 // Save setting for new template only if it is not empty.
1040 if ( ! $new_template ) {
1041 return;
1042 }
1043
1044 $options = $_POST[ $new_template ];
1045
1046 // Exit
1047 if ( empty( $options ) ) {
1048 return;
1049 }
1050
1051 /* @var Template $template */
1052 $template = Give()->templates->getTemplate( $new_template );
1053
1054 // If selected theme is not registered then do not save it's options.
1055 if ( null === $template ) {
1056 return;
1057 }
1058
1059 /* @var Template\Options $templateOptions */
1060 $templateOptions = $template->getOptions();
1061 $saveOptions = FormTemplateUtils::getOptions( $formID );
1062
1063 /* @var Section $group */
1064 foreach ( $templateOptions->sections as $group ) {
1065 /* @var Fields $field */
1066 foreach ( $group->fields as $field ) {
1067 if ( ! isset( $options[ $group->id ][ $field->id ] ) ) {
1068 continue;
1069 }
1070
1071 // Initialize $value for every field to prevent value type conflict.
1072 $value = null;
1073
1074 switch ( $field->type ) {
1075 case 'textarea':
1076 case 'wysiwyg':
1077 $value = wp_kses_post( $options[ $group->id ][ $field->id ] );
1078 break;
1079
1080 case 'donation_limit':
1081 $value = $options[ $group->id ][ $field->id ];
1082 break;
1083
1084 case 'group':
1085 /* @var \Give\FormAPI\Form\Group $field */
1086 foreach ( $options[ $group->id ][ $field->id ] as $index => $subFields ) {
1087
1088 // Do not save template input field values.
1089 if ( '{{row-count-placeholder}}' === $index ) {
1090 continue;
1091 }
1092
1093 $group_of_values = [];
1094
1095 foreach ( $subFields as $field_id => $field_value ) {
1096 switch ( $field->getFieldArguments( $field_id )['type'] ) {
1097 case 'wysiwyg':
1098 $group_of_values[ $field_id ] = wp_kses_post( $field_value );
1099 break;
1100
1101 default:
1102 $group_of_values[ $field_id ] = give_clean( $field_value );
1103 }
1104 }
1105
1106 if ( ! empty( $group_of_values ) ) {
1107 $value[ $index ] = $group_of_values;
1108 }
1109 }
1110
1111 // Arrange repeater field keys in order.
1112 $value = $value ? array_values( $value ) : [];
1113 break;
1114
1115 default:
1116 $value = give_clean( $options[ $group->id ][ $field->id ] );
1117 }// End switch().
1118
1119 $saveOptions[ $group->id ][ $field->id ] = $value;
1120 }
1121 }
1122
1123 FormTemplateUtils::saveOptions( $formID, $saveOptions );
1124 }
1125
1126
1127 /**
1128 * Get field ID.
1129 *
1130 * @param array $field Array of Fields.
1131 *
1132 * @since 1.8
1133 *
1134 * @return string
1135 */
1136 private function get_field_id( $field ) {
1137 $field_id = '';
1138
1139 if ( array_key_exists( 'id', $field ) ) {
1140 $field_id = $field['id'];
1141
1142 }
1143
1144 return $field_id;
1145 }
1146
1147 /**
1148 * Get fields ID.
1149 *
1150 * @param array $setting Array of settings.
1151 *
1152 * @since 1.8
1153 *
1154 * @return array
1155 */
1156 private function get_fields_id( $setting ) {
1157 $meta_keys = [];
1158
1159 if (
1160 ! empty( $setting )
1161 && array_key_exists( 'fields', $setting )
1162 && ! empty( $setting['fields'] )
1163 ) {
1164 foreach ( $setting['fields'] as $field ) {
1165 if ( $field_id = $this->get_field_id( $field ) ) {
1166 $meta_keys[] = $field_id;
1167 }
1168 }
1169 }
1170
1171 return $meta_keys;
1172 }
1173
1174 /**
1175 * Get sub fields ID.
1176 *
1177 * @param array $setting Array of settings.
1178 *
1179 * @since 1.8
1180 *
1181 * @return array
1182 */
1183 private function get_sub_fields_id( $setting ) {
1184 $meta_keys = [];
1185
1186 if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) {
1187 foreach ( $setting['sub-fields'] as $fields ) {
1188 if ( ! empty( $fields['fields'] ) ) {
1189 foreach ( $fields['fields'] as $field ) {
1190 if ( $field_id = $this->get_field_id( $field ) ) {
1191 $meta_keys[] = $field_id;
1192 }
1193 }
1194 }
1195 }
1196 }
1197
1198 return $meta_keys;
1199 }
1200
1201
1202 /**
1203 * Get all setting field ids.
1204 *
1205 * @since 1.8
1206 *
1207 * @return array
1208 */
1209 private function get_meta_keys_from_settings() {
1210 $meta_keys = [];
1211
1212 foreach ( $this->settings as $setting ) {
1213 $meta_key = $this->get_fields_id( $setting );
1214
1215 if ( $this->has_sub_tab( $setting ) ) {
1216 $meta_key = array_merge( $meta_key, $this->get_sub_fields_id( $setting ) );
1217 }
1218
1219 $meta_keys = array_merge( $meta_keys, $meta_key );
1220 }
1221
1222 return $meta_keys;
1223 }
1224
1225
1226 /**
1227 * Get field type.
1228 *
1229 * @param string $field_id Field ID.
1230 * @param string $group_id Field Group ID.
1231 *
1232 * @since 1.8
1233 *
1234 * @return string
1235 */
1236 function get_field_type( $field_id, $group_id = '' ) {
1237 $field = $this->get_setting_field( $field_id, $group_id );
1238
1239 $type = array_key_exists( 'type', $field )
1240 ? $field['type']
1241 : '';
1242
1243 return $type;
1244 }
1245
1246
1247 /**
1248 * Get Field
1249 *
1250 * @param array $setting Settings array.
1251 * @param string $field_id Field ID.
1252 *
1253 * @since 1.8
1254 *
1255 * @return array
1256 */
1257 private function get_field( $setting, $field_id ) {
1258 $setting_field = [];
1259
1260 if ( ! empty( $setting['fields'] ) ) {
1261 foreach ( $setting['fields'] as $field ) {
1262 if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) {
1263 $setting_field = $field;
1264 break;
1265 }
1266 }
1267 }
1268
1269 return $setting_field;
1270 }
1271
1272 /**
1273 * Get Sub Field
1274 *
1275 * @param array $setting Settings array.
1276 * @param string $field_id Field ID.
1277 *
1278 * @since 1.8
1279 *
1280 * @return array
1281 */
1282 private function get_sub_field( $setting, $field_id ) {
1283 $setting_field = [];
1284
1285 if ( ! empty( $setting['sub-fields'] ) ) {
1286 foreach ( $setting['sub-fields'] as $fields ) {
1287 if ( $field = $this->get_field( $fields, $field_id ) ) {
1288 $setting_field = $field;
1289 break;
1290 }
1291 }
1292 }
1293
1294 return $setting_field;
1295 }
1296
1297 /**
1298 * Get setting field.
1299 *
1300 * @param string $field_id Field ID.
1301 * @param string $group_id Get sub field from group.
1302 *
1303 * @since 1.8
1304 *
1305 * @return array
1306 */
1307 function get_setting_field( $field_id, $group_id = '' ) {
1308 $setting_field = [];
1309
1310 $_field_id = $field_id;
1311 $field_id = empty( $group_id ) ? $field_id : $group_id;
1312
1313 if ( ! empty( $this->settings ) ) {
1314 foreach ( $this->settings as $setting ) {
1315 if (
1316 ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) )
1317 || ( $setting_field = $this->get_field( $setting, $field_id ) )
1318 ) {
1319 break;
1320 }
1321 }
1322 }
1323
1324 // Get field from group.
1325 if ( ! empty( $group_id ) ) {
1326 foreach ( $setting_field['fields'] as $field ) {
1327 if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) {
1328 $setting_field = $field;
1329 }
1330 }
1331 }
1332
1333 return $setting_field;
1334 }
1335
1336
1337 /**
1338 * Add offline donations setting tab to donation form options metabox.
1339 *
1340 * @param array $settings List of form settings.
1341 *
1342 * @since 1.8
1343 *
1344 * @return mixed
1345 */
1346 function add_offline_donations_setting_tab( $settings ) {
1347 if ( give_is_gateway_active( 'offline' ) ) {
1348 $settings['offline_donations_options'] = apply_filters(
1349 'give_forms_offline_donations_options',
1350 [
1351 'id' => 'offline_donations_options',
1352 'title' => __( 'Offline Donations', 'give' ),
1353 'icon-html' => '<i class="fas fa-wallet"></i>',
1354 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', [] ),
1355 ]
1356 );
1357 }
1358
1359 return $settings;
1360 }
1361
1362
1363 /**
1364 * Sanitize form meta values before saving.
1365 *
1366 * @param mixed $meta_value Meta Value for sanitizing before saving.
1367 * @param array $setting_field Setting Field.
1368 *
1369 * @since 1.8.9
1370 * @access public
1371 *
1372 * @return mixed
1373 */
1374 function sanitize_form_meta( $meta_value, $setting_field ) {
1375 switch ( $setting_field['type'] ) {
1376 case 'group':
1377 if ( ! empty( $setting_field['fields'] ) ) {
1378 foreach ( $setting_field['fields'] as $field ) {
1379 if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) {
1380 continue;
1381 }
1382
1383 foreach ( $meta_value as $index => $meta_data ) {
1384 if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) {
1385 continue;
1386 }
1387
1388 $meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) ?
1389 give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) :
1390 ( ( '_give_amount' === $field['id'] && empty( $field_value ) ) ?
1391 give_sanitize_amount_for_db( '1.00' ) :
1392 0 );
1393 }
1394 }
1395 }
1396 break;
1397
1398 default:
1399 if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) {
1400 $meta_value = $meta_value ?
1401 give_sanitize_amount_for_db( $meta_value ) :
1402 ( in_array(
1403 $setting_field['id'],
1404 [
1405 '_give_set_price',
1406 '_give_custom_amount_minimum',
1407 '_give_set_goal',
1408 ]
1409 ) ?
1410 give_sanitize_amount_for_db( '1.00' ) :
1411 0 );
1412 }
1413 }
1414
1415 return $meta_value;
1416 }
1417
1418 /**
1419 * Maintain the active tab after save.
1420 *
1421 * @param string $location The destination URL.
1422 * @param int $post_id The post ID.
1423 *
1424 * @since 1.8.13
1425 * @access public
1426 *
1427 * @return string The URL after redirect.
1428 */
1429 public function maintain_active_tab( $location, $post_id ) {
1430 if (
1431 'give_forms' === get_post_type( $post_id ) &&
1432 ! empty( $_POST['give_form_active_tab'] )
1433 ) {
1434 $location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location );
1435 }
1436
1437 return $location;
1438 }
1439 }
1440
1441 new Give_MetaBox_Form_Data();
1442
1443