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