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