PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.17.1
GiveWP – Donation Plugin and Fundraising Platform v2.17.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 / 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 5 years ago metabox.php 6 years ago
class-metabox-form-data.php
1442 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 'attributes' => [
475 'placeholder' => $price_placeholder,
476 'class' => 'give-money-field',
477 ],
478 'wrapper_class' => 'give-hidden',
479 ],
480 [
481 'id' => $prefix . 'number_of_donation_goal',
482 'name' => __( 'Donation Goal', 'give' ),
483 'desc' => __( 'Set the total number of donations as a goal.', 'give' ),
484 'type' => 'number',
485 'default' => 1,
486 'attributes' => [
487 'placeholder' => 1,
488 ],
489 ],
490 [
491 'id' => $prefix . 'number_of_donor_goal',
492 'name' => __( 'Donor Goal', 'give' ),
493 'desc' => __( 'Set the total number of donors as a goal.', 'give' ),
494 'type' => 'number',
495 'default' => 1,
496 'attributes' => [
497 'placeholder' => 1,
498 ],
499 ],
500 [
501 'name' => __( 'Progress Bar Color', 'give' ),
502 'desc' => __( 'Customize the color of the goal progress bar.', 'give' ),
503 'id' => $prefix . 'goal_color',
504 'type' => 'colorpicker',
505 'default' => '#2bc253',
506 'wrapper_class' => 'give-hidden',
507 ],
508
509 [
510 'name' => __( 'Close Form', 'give' ),
511 'desc' => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ),
512 'id' => $prefix . 'close_form_when_goal_achieved',
513 'type' => 'radio_inline',
514 'default' => 'disabled',
515 'options' => [
516 'enabled' => __( 'Enabled', 'give' ),
517 'disabled' => __( 'Disabled', 'give' ),
518 ],
519 'wrapper_class' => 'give-hidden',
520 ],
521 [
522 'name' => __( 'Goal Achieved Message', 'give' ),
523 'desc' => __( 'Do you want to display a custom message when the goal is closed?', 'give' ),
524 'id' => $prefix . 'form_goal_achieved_message',
525 'type' => 'wysiwyg',
526 'default' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ),
527 'wrapper_class' => 'give-hidden',
528 ],
529 [
530 'name' => 'donation_goal_docs',
531 'type' => 'docs_link',
532 'url' => 'http://docs.givewp.com/form-donation-goal',
533 'title' => __( 'Donation Goal', 'give' ),
534 ],
535 ],
536 $post_id
537 ),
538 ]
539 ),
540
541 /**
542 * Terms & Conditions
543 */
544 'form_terms_options' => apply_filters(
545 'give_forms_terms_options',
546 [
547 'id' => 'form_terms_options',
548 'title' => __( 'Terms & Conditions', 'give' ),
549 'icon-html' => '<i class="far fa-check-square"></i>',
550 'fields' => apply_filters(
551 'give_forms_terms_options_metabox_fields',
552 [
553 // Donation Option
554 [
555 'name' => __( 'Terms and Conditions', 'give' ),
556 'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ),
557 'id' => $prefix . 'terms_option',
558 'type' => 'radio_inline',
559 'options' => apply_filters(
560 'give_forms_content_options_select',
561 [
562 'global' => __( 'Global Option', 'give' ),
563 'enabled' => __( 'Customize', 'give' ),
564 'disabled' => __( 'Disable', 'give' ),
565 ]
566 ),
567 'default' => 'global',
568 ],
569 [
570 'id' => $prefix . 'agree_label',
571 'name' => __( 'Agreement Label', 'give' ),
572 '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' ),
573 'type' => 'textarea',
574 'attributes' => [
575 'placeholder' => __( 'Agree to Terms?', 'give' ),
576 'rows' => 1,
577 ],
578 'wrapper_class' => 'give-hidden',
579 ],
580 [
581 'id' => $prefix . 'agree_text',
582 'name' => __( 'Agreement Text', 'give' ),
583 'desc' => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ),
584 'default' => give_get_option( 'agreement_text' ),
585 'type' => 'wysiwyg',
586 'wrapper_class' => 'give-hidden',
587 ],
588 [
589 'name' => 'terms_docs',
590 'type' => 'docs_link',
591 'url' => 'http://docs.givewp.com/form-terms',
592 'title' => __( 'Terms and Conditions', 'give' ),
593 ],
594 ],
595 $post_id
596 ),
597 ]
598 ),
599 ];
600
601 /**
602 * Filter the metabox tabbed panel settings.
603 */
604 $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id );
605
606 // Output.
607 return $settings;
608 }
609
610 /**
611 * Add metabox.
612 *
613 * @since 1.8
614 *
615 * @return void
616 */
617 public function add_meta_box() {
618 add_meta_box(
619 $this->get_metabox_ID(),
620 $this->get_metabox_label(),
621 [ $this, 'output' ],
622 [ 'give_forms' ],
623 'normal',
624 'high'
625 );
626
627 // Show Goal Metabox only if goal is enabled.
628 if ( give_is_setting_enabled( give_get_meta( give_get_admin_post_id(), '_give_goal_option', true ) ) ) {
629 add_meta_box(
630 'give-form-goal-stats',
631 __( 'Goal Statistics', 'give' ),
632 [ $this, 'output_goal' ],
633 [ 'give_forms' ],
634 'side',
635 'low'
636 );
637 }
638
639 }
640
641
642 /**
643 * Enqueue scripts.
644 *
645 * @since 1.8
646 *
647 * @return void
648 */
649 function enqueue_script() {
650 global $post;
651
652 if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
653
654 }
655 }
656
657 /**
658 * Get metabox id.
659 *
660 * @since 1.8
661 *
662 * @return string
663 */
664 function get_metabox_ID() {
665 return $this->metabox_id;
666 }
667
668 /**
669 * Get metabox label.
670 *
671 * @since 1.8
672 *
673 * @return string
674 */
675 function get_metabox_label() {
676 return $this->metabox_label;
677 }
678
679
680 /**
681 * Get metabox tabs.
682 *
683 * @since 1.8
684 *
685 * @return array
686 */
687 public function get_tabs() {
688 $tabs = [];
689
690 if ( ! empty( $this->settings ) ) {
691 foreach ( $this->settings as $setting ) {
692 if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) {
693 continue;
694 }
695 $tab = [
696 'id' => $setting['id'],
697 'label' => $setting['title'],
698 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ),
699 ];
700
701 if ( $this->has_sub_tab( $setting ) ) {
702 if ( empty( $setting['sub-fields'] ) ) {
703 $tab = [];
704 } else {
705 foreach ( $setting['sub-fields'] as $sub_fields ) {
706 $tab['sub-fields'][] = [
707 'id' => $sub_fields['id'],
708 'label' => $sub_fields['title'],
709 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ),
710 ];
711 }
712 }
713 }
714
715 if ( ! empty( $tab ) ) {
716 $tabs[] = $tab;
717 }
718 }
719 }
720
721 return $tabs;
722 }
723
724 /**
725 * Output metabox settings.
726 *
727 * @since 1.8
728 *
729 * @return void
730 */
731 public function output() {
732 // Bailout.
733 if ( $form_data_tabs = $this->get_tabs() ) :
734 Template\LegacyFormSettingCompatibility::migrateExistingFormSettings();
735
736 $active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_template_options';
737 wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' );
738
739 $added_upsells_notice = false;
740 ?>
741 <input id="give_form_active_tab" type="hidden" name="give_form_active_tab">
742 <div class="give-metabox-panel-wrap">
743 <ul class="give-form-data-tabs give-metabox-tabs">
744 <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?>
745 <?php
746 // Determine if current tab is active.
747 $is_active = $active_tab === $form_data_tab['id'] ? true : false;
748 ?>
749 <li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>">
750 <a href="#<?php echo $form_data_tab['id']; ?>"
751 data-tab-id="<?php echo $form_data_tab['id']; ?>">
752 <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?>
753 <?php echo $form_data_tab['icon-html']; ?>
754 <?php else : ?>
755 <i class="fas fa-angle-right"></i>
756 <?php endif; ?>
757 <span class="give-label"><?php echo $form_data_tab['label']; ?></span>
758 </a>
759 <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?>
760 <ul class="give-metabox-sub-tabs give-hidden">
761 <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?>
762 <li class="<?php echo "{$sub_tab['id']}_tab"; ?>">
763 <a href="#<?php echo $sub_tab['id']; ?>"
764 data-tab-id="<?php echo $sub_tab['id']; ?>">
765 <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?>
766 <?php echo $sub_tab['icon-html']; ?>
767 <?php else : ?>
768 <i class="fas fa-angle-right"></i>
769 <?php endif; ?>
770 <span class="give-label"><?php echo $sub_tab['label']; ?></span>
771 </a>
772 </li>
773 <?php endforeach; ?>
774 </ul>
775 <?php endif; ?>
776 </li>
777 <?php endforeach; ?>
778 </ul>
779
780 <?php foreach ( $this->settings as $setting ) : ?>
781 <?php do_action( "give_before_{$setting['id']}_settings" ); ?>
782 <?php
783 // Determine if current panel is active.
784 $is_active = $active_tab === $setting['id'];
785 ?>
786 <div id="<?php echo $setting['id']; ?>"
787 class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>">
788 <?php
789 if ( ! $added_upsells_notice ) {
790 echo UpsellNotice::recurringAddon();
791 $added_upsells_notice = true;
792 }
793 ?>
794 <?php if ( ! empty( $setting['fields'] ) ) : ?>
795 <?php foreach ( $setting['fields'] as $field ) : ?>
796 <?php give_render_field( $field ); ?>
797 <?php endforeach; ?>
798 <?php endif; ?>
799 <?php do_action( "give_post_{$setting['id']}_settings" ); ?>
800 </div>
801 <?php do_action( "give_after_{$setting['id']}_settings" ); ?>
802
803
804 <?php if ( $this->has_sub_tab( $setting ) ) : ?>
805 <?php if ( ! empty( $setting['sub-fields'] ) ) : ?>
806 <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?>
807 <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden">
808 <?php if ( ! empty( $sub_fields['fields'] ) ) : ?>
809 <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?>
810 <?php give_render_field( $sub_field ); ?>
811 <?php endforeach; ?>
812 <?php endif; ?>
813 </div>
814 <?php endforeach; ?>
815 <?php endif; ?>
816 <?php endif; ?>
817 <?php endforeach; ?>
818 </div>
819 <?php
820 endif; // End if().
821 }
822
823 /**
824 * Output Goal meta-box settings.
825 *
826 * @param object $post Post Object.
827 *
828 * @access public
829 * @since 2.1.0
830 *
831 * @return void
832 */
833 public function output_goal( $post ) {
834
835 echo give_admin_form_goal_stats( $post->ID );
836
837 }
838
839 /**
840 * Check if setting field has sub tabs/fields
841 *
842 * @param array $field_setting Field Settings.
843 *
844 * @since 1.8
845 *
846 * @return bool
847 */
848 private function has_sub_tab( $field_setting ) {
849 $has_sub_tab = false;
850 if ( array_key_exists( 'sub-fields', $field_setting ) ) {
851 $has_sub_tab = true;
852 }
853
854 return $has_sub_tab;
855 }
856
857 /**
858 * CMB2 settings loader.
859 *
860 * @since 1.8
861 *
862 * @return array
863 */
864 function cmb2_metabox_settings() {
865 $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', [] );
866 $give_forms_settings = $all_cmb2_settings;
867
868 // Filter settings: Use only give forms related settings.
869 foreach ( $all_cmb2_settings as $index => $setting ) {
870 if ( ! in_array( 'give_forms', $setting['object_types'] ) ) {
871 unset( $give_forms_settings[ $index ] );
872 }
873 }
874
875 return $give_forms_settings;
876
877 }
878
879 /**
880 * Check if we're saving, the trigger an action based on the post type.
881 *
882 * @param int $post_id Post ID.
883 * @param int|object $post Post Object.
884 *
885 * @since 1.8
886 *
887 * @return void
888 */
889 public function save( $post_id, $post ) {
890
891 // $post_id and $post are required.
892 if ( empty( $post_id ) || empty( $post ) ) {
893 return;
894 }
895
896 // Don't save meta boxes for revisions or autosaves.
897 if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
898 return;
899 }
900
901 // Check the nonce.
902 if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) {
903 return;
904 }
905
906 // Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
907 if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) {
908 return;
909 }
910
911 // Check user has permission to edit.
912 if ( ! current_user_can( 'edit_post', $post_id ) ) {
913 return;
914 }
915
916 // Fire action before saving form meta.
917 do_action( 'give_pre_process_give_forms_meta', $post_id, $post );
918
919 /**
920 * Filter the meta key to save.
921 * Third party addon developer can remove there meta keys from this array to handle saving data on there own.
922 */
923 $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() );
924
925 // Save form meta data.
926 if ( ! empty( $form_meta_keys ) ) {
927 foreach ( $form_meta_keys as $form_meta_key ) {
928
929 // Set default value for checkbox fields.
930 if (
931 ! isset( $_POST[ $form_meta_key ] ) &&
932 in_array( $this->get_field_type( $form_meta_key ), [ 'checkbox', 'chosen', 'multicheck' ] )
933 ) {
934 $_POST[ $form_meta_key ] = '';
935 }
936
937 if ( isset( $_POST[ $form_meta_key ] ) ) {
938 $setting_field = $this->get_setting_field( $form_meta_key );
939 if ( ! empty( $setting_field['type'] ) ) {
940 switch ( $setting_field['type'] ) {
941 case 'textarea':
942 case 'wysiwyg':
943 $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] );
944 break;
945
946 case 'donation_limit':
947 $form_meta_value = $_POST[ $form_meta_key ];
948 break;
949
950 case 'group':
951 $form_meta_value = [];
952
953 foreach ( $_POST[ $form_meta_key ] as $index => $group ) {
954
955 // Do not save template input field values.
956 if ( '{{row-count-placeholder}}' === $index ) {
957 continue;
958 }
959
960 $group_meta_value = [];
961 foreach ( $group as $field_id => $field_value ) {
962 switch ( $this->get_field_type( $field_id, $form_meta_key ) ) {
963 case 'wysiwyg':
964 $group_meta_value[ $field_id ] = wp_kses_post( $field_value );
965 break;
966
967 default:
968 $group_meta_value[ $field_id ] = give_clean( $field_value );
969 }
970 }
971
972 if ( ! empty( $group_meta_value ) ) {
973 $form_meta_value[ $index ] = $group_meta_value;
974 }
975 }
976
977 // Arrange repeater field keys in order.
978 $form_meta_value = array_values( $form_meta_value );
979 break;
980
981 default:
982 $form_meta_value = give_clean( $_POST[ $form_meta_key ] );
983 }// End switch().
984
985 /**
986 * Filter the form meta value before saving
987 *
988 * @since 1.8.9
989 */
990 $form_meta_value = apply_filters(
991 'give_pre_save_form_meta_value',
992 $this->sanitize_form_meta( $form_meta_value, $setting_field ),
993 $form_meta_key,
994 $this,
995 $post_id
996 );
997
998 // Range slider.
999 if ( 'donation_limit' === $setting_field['type'] ) {
1000
1001 // Sanitize amount for db.
1002 $form_meta_value = array_map( 'give_sanitize_amount_for_db', $form_meta_value );
1003
1004 // Store it to form meta.
1005 give_update_meta( $post_id, $form_meta_key . '_minimum', $form_meta_value['minimum'] );
1006 give_update_meta( $post_id, $form_meta_key . '_maximum', $form_meta_value['maximum'] );
1007 } else {
1008 // Save data.
1009 give_update_meta( $post_id, $form_meta_key, $form_meta_value );
1010 }
1011
1012 // Verify and delete form meta based on the form status.
1013 give_set_form_closed_status( $post_id );
1014
1015 // Fire after saving form meta key.
1016 do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post );
1017 }// End if().
1018 }// End if().
1019 }// End foreach().
1020 }// End if().
1021
1022 // Update the goal progress for donation form.
1023 give_update_goal_progress( $post_id );
1024
1025 // Fire action after saving form meta.
1026 do_action( 'give_post_process_give_forms_meta', $post_id, $post );
1027 }
1028
1029
1030 /**
1031 * Save form template setting handler
1032 *
1033 * @param string $meta_key
1034 * @param string $new_template
1035 * @param int $formID
1036 */
1037 public function save_form_template_settings( $meta_key, $new_template, $formID ) {
1038 // Save setting for new template only if it is not empty.
1039 if ( ! $new_template ) {
1040 return;
1041 }
1042
1043 $options = $_POST[ $new_template ];
1044
1045 // Exit
1046 if ( empty( $options ) ) {
1047 return;
1048 }
1049
1050 /* @var Template $template */
1051 $template = Give()->templates->getTemplate( $new_template );
1052
1053 // If selected theme is not registered then do not save it's options.
1054 if ( null === $template ) {
1055 return;
1056 }
1057
1058 /* @var Template\Options $templateOptions */
1059 $templateOptions = $template->getOptions();
1060 $saveOptions = FormTemplateUtils::getOptions( $formID );
1061
1062 /* @var Section $group */
1063 foreach ( $templateOptions->sections as $group ) {
1064 /* @var Fields $field */
1065 foreach ( $group->fields as $field ) {
1066 if ( ! isset( $options[ $group->id ][ $field->id ] ) ) {
1067 continue;
1068 }
1069
1070 // Initialize $value for every field to prevent value type conflict.
1071 $value = null;
1072
1073 switch ( $field->type ) {
1074 case 'textarea':
1075 case 'wysiwyg':
1076 $value = wp_kses_post( $options[ $group->id ][ $field->id ] );
1077 break;
1078
1079 case 'donation_limit':
1080 $value = $options[ $group->id ][ $field->id ];
1081 break;
1082
1083 case 'group':
1084 /* @var \Give\FormAPI\Form\Group $field */
1085 foreach ( $options[ $group->id ][ $field->id ] as $index => $subFields ) {
1086
1087 // Do not save template input field values.
1088 if ( '{{row-count-placeholder}}' === $index ) {
1089 continue;
1090 }
1091
1092 $group_of_values = [];
1093
1094 foreach ( $subFields as $field_id => $field_value ) {
1095 switch ( $field->getFieldArguments( $field_id )['type'] ) {
1096 case 'wysiwyg':
1097 $group_of_values[ $field_id ] = wp_kses_post( $field_value );
1098 break;
1099
1100 default:
1101 $group_of_values[ $field_id ] = give_clean( $field_value );
1102 }
1103 }
1104
1105 if ( ! empty( $group_of_values ) ) {
1106 $value[ $index ] = $group_of_values;
1107 }
1108 }
1109
1110 // Arrange repeater field keys in order.
1111 $value = $value ? array_values( $value ) : [];
1112 break;
1113
1114 default:
1115 $value = give_clean( $options[ $group->id ][ $field->id ] );
1116 }// End switch().
1117
1118 $saveOptions[ $group->id ][ $field->id ] = $value;
1119 }
1120 }
1121
1122 FormTemplateUtils::saveOptions( $formID, $saveOptions );
1123 }
1124
1125
1126 /**
1127 * Get field ID.
1128 *
1129 * @param array $field Array of Fields.
1130 *
1131 * @since 1.8
1132 *
1133 * @return string
1134 */
1135 private function get_field_id( $field ) {
1136 $field_id = '';
1137
1138 if ( array_key_exists( 'id', $field ) ) {
1139 $field_id = $field['id'];
1140
1141 }
1142
1143 return $field_id;
1144 }
1145
1146 /**
1147 * Get fields ID.
1148 *
1149 * @param array $setting Array of settings.
1150 *
1151 * @since 1.8
1152 *
1153 * @return array
1154 */
1155 private function get_fields_id( $setting ) {
1156 $meta_keys = [];
1157
1158 if (
1159 ! empty( $setting )
1160 && array_key_exists( 'fields', $setting )
1161 && ! empty( $setting['fields'] )
1162 ) {
1163 foreach ( $setting['fields'] as $field ) {
1164 if ( $field_id = $this->get_field_id( $field ) ) {
1165 $meta_keys[] = $field_id;
1166 }
1167 }
1168 }
1169
1170 return $meta_keys;
1171 }
1172
1173 /**
1174 * Get sub fields ID.
1175 *
1176 * @param array $setting Array of settings.
1177 *
1178 * @since 1.8
1179 *
1180 * @return array
1181 */
1182 private function get_sub_fields_id( $setting ) {
1183 $meta_keys = [];
1184
1185 if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) {
1186 foreach ( $setting['sub-fields'] as $fields ) {
1187 if ( ! empty( $fields['fields'] ) ) {
1188 foreach ( $fields['fields'] as $field ) {
1189 if ( $field_id = $this->get_field_id( $field ) ) {
1190 $meta_keys[] = $field_id;
1191 }
1192 }
1193 }
1194 }
1195 }
1196
1197 return $meta_keys;
1198 }
1199
1200
1201 /**
1202 * Get all setting field ids.
1203 *
1204 * @since 1.8
1205 *
1206 * @return array
1207 */
1208 private function get_meta_keys_from_settings() {
1209 $meta_keys = [];
1210
1211 foreach ( $this->settings as $setting ) {
1212 $meta_key = $this->get_fields_id( $setting );
1213
1214 if ( $this->has_sub_tab( $setting ) ) {
1215 $meta_key = array_merge( $meta_key, $this->get_sub_fields_id( $setting ) );
1216 }
1217
1218 $meta_keys = array_merge( $meta_keys, $meta_key );
1219 }
1220
1221 return $meta_keys;
1222 }
1223
1224
1225 /**
1226 * Get field type.
1227 *
1228 * @param string $field_id Field ID.
1229 * @param string $group_id Field Group ID.
1230 *
1231 * @since 1.8
1232 *
1233 * @return string
1234 */
1235 function get_field_type( $field_id, $group_id = '' ) {
1236 $field = $this->get_setting_field( $field_id, $group_id );
1237
1238 $type = array_key_exists( 'type', $field )
1239 ? $field['type']
1240 : '';
1241
1242 return $type;
1243 }
1244
1245
1246 /**
1247 * Get Field
1248 *
1249 * @param array $setting Settings array.
1250 * @param string $field_id Field ID.
1251 *
1252 * @since 1.8
1253 *
1254 * @return array
1255 */
1256 private function get_field( $setting, $field_id ) {
1257 $setting_field = [];
1258
1259 if ( ! empty( $setting['fields'] ) ) {
1260 foreach ( $setting['fields'] as $field ) {
1261 if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) {
1262 $setting_field = $field;
1263 break;
1264 }
1265 }
1266 }
1267
1268 return $setting_field;
1269 }
1270
1271 /**
1272 * Get Sub Field
1273 *
1274 * @param array $setting Settings array.
1275 * @param string $field_id Field ID.
1276 *
1277 * @since 1.8
1278 *
1279 * @return array
1280 */
1281 private function get_sub_field( $setting, $field_id ) {
1282 $setting_field = [];
1283
1284 if ( ! empty( $setting['sub-fields'] ) ) {
1285 foreach ( $setting['sub-fields'] as $fields ) {
1286 if ( $field = $this->get_field( $fields, $field_id ) ) {
1287 $setting_field = $field;
1288 break;
1289 }
1290 }
1291 }
1292
1293 return $setting_field;
1294 }
1295
1296 /**
1297 * Get setting field.
1298 *
1299 * @param string $field_id Field ID.
1300 * @param string $group_id Get sub field from group.
1301 *
1302 * @since 1.8
1303 *
1304 * @return array
1305 */
1306 function get_setting_field( $field_id, $group_id = '' ) {
1307 $setting_field = [];
1308
1309 $_field_id = $field_id;
1310 $field_id = empty( $group_id ) ? $field_id : $group_id;
1311
1312 if ( ! empty( $this->settings ) ) {
1313 foreach ( $this->settings as $setting ) {
1314 if (
1315 ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) )
1316 || ( $setting_field = $this->get_field( $setting, $field_id ) )
1317 ) {
1318 break;
1319 }
1320 }
1321 }
1322
1323 // Get field from group.
1324 if ( ! empty( $group_id ) ) {
1325 foreach ( $setting_field['fields'] as $field ) {
1326 if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) {
1327 $setting_field = $field;
1328 }
1329 }
1330 }
1331
1332 return $setting_field;
1333 }
1334
1335
1336 /**
1337 * Add offline donations setting tab to donation form options metabox.
1338 *
1339 * @param array $settings List of form settings.
1340 *
1341 * @since 1.8
1342 *
1343 * @return mixed
1344 */
1345 function add_offline_donations_setting_tab( $settings ) {
1346 if ( give_is_gateway_active( 'offline' ) ) {
1347 $settings['offline_donations_options'] = apply_filters(
1348 'give_forms_offline_donations_options',
1349 [
1350 'id' => 'offline_donations_options',
1351 'title' => __( 'Offline Donations', 'give' ),
1352 'icon-html' => '<i class="fas fa-wallet"></i>',
1353 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', [] ),
1354 ]
1355 );
1356 }
1357
1358 return $settings;
1359 }
1360
1361
1362 /**
1363 * Sanitize form meta values before saving.
1364 *
1365 * @param mixed $meta_value Meta Value for sanitizing before saving.
1366 * @param array $setting_field Setting Field.
1367 *
1368 * @since 1.8.9
1369 * @access public
1370 *
1371 * @return mixed
1372 */
1373 function sanitize_form_meta( $meta_value, $setting_field ) {
1374 switch ( $setting_field['type'] ) {
1375 case 'group':
1376 if ( ! empty( $setting_field['fields'] ) ) {
1377 foreach ( $setting_field['fields'] as $field ) {
1378 if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) {
1379 continue;
1380 }
1381
1382 foreach ( $meta_value as $index => $meta_data ) {
1383 if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) {
1384 continue;
1385 }
1386
1387 $meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) ?
1388 give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) :
1389 ( ( '_give_amount' === $field['id'] && empty( $field_value ) ) ?
1390 give_sanitize_amount_for_db( '1.00' ) :
1391 0 );
1392 }
1393 }
1394 }
1395 break;
1396
1397 default:
1398 if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) {
1399 $meta_value = $meta_value ?
1400 give_sanitize_amount_for_db( $meta_value ) :
1401 ( in_array(
1402 $setting_field['id'],
1403 [
1404 '_give_set_price',
1405 '_give_custom_amount_minimum',
1406 '_give_set_goal',
1407 ]
1408 ) ?
1409 give_sanitize_amount_for_db( '1.00' ) :
1410 0 );
1411 }
1412 }
1413
1414 return $meta_value;
1415 }
1416
1417 /**
1418 * Maintain the active tab after save.
1419 *
1420 * @param string $location The destination URL.
1421 * @param int $post_id The post ID.
1422 *
1423 * @since 1.8.13
1424 * @access public
1425 *
1426 * @return string The URL after redirect.
1427 */
1428 public function maintain_active_tab( $location, $post_id ) {
1429 if (
1430 'give_forms' === get_post_type( $post_id ) &&
1431 ! empty( $_POST['give_form_active_tab'] )
1432 ) {
1433 $location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location );
1434 }
1435
1436 return $location;
1437 }
1438 }
1439
1440 new Give_MetaBox_Form_Data();
1441
1442