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