PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 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 All 256 releases
← All changes | includes/admin/give-metabox-functions.php +335 -446 2.3.0 → 4.17.0 View file →
@@ -3,9 +3,9 @@
3 3 * Give Meta Box Functions
4 4 *
5 5 * @package Give
6 6 * @subpackage Functions
7 - * @copyright Copyright (c) 2016, WordImpress
7 + * @copyright Copyright (c) 2016, GiveWP
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9 * @since 1.8
10 10 */
11 11 if ( ! defined( 'ABSPATH' ) ) {
@@ -47,28 +47,29 @@
47 47
48 48 case 'text':
49 49 case 'text-medium':
50 50 case 'text_medium':
51 - case 'text-small' :
52 - case 'text_small' :
53 - case 'number' :
54 - case 'email' :
51 + case 'text-small':
52 + case 'text_small':
53 + case 'number':
54 + case 'email':
55 55 $func_name = "{$func_name_prefix}_text_input";
56 56 break;
57 57
58 - case 'textarea' :
58 + case 'textarea':
59 59 $func_name = "{$func_name_prefix}_textarea_input";
60 60 break;
61 61
62 - case 'colorpicker' :
62 + case 'colorpicker':
63 63 $func_name = "{$func_name_prefix}_{$field['type']}";
64 64 break;
65 65
66 + case 'hidden':
66 67 case 'levels_id':
67 68 $func_name = "{$func_name_prefix}_hidden_input";
68 69 break;
69 70
70 - case 'group' :
71 + case 'group':
71 72 $func_name = "_{$func_name_prefix}_metabox_form_data_repeater_fields";
72 73 break;
73 74
74 75 case 'give_default_radio_inline':
@@ -82,10 +83,13 @@
82 83 case 'chosen':
83 84 $func_name = "{$func_name_prefix}_chosen_input";
84 85 break;
85 86
87 + case 'label':
88 + $func_name = "{$func_name_prefix}_label_field";
89 + break;
90 +
86 91 default:
87 -
88 92 if (
89 93 array_key_exists( 'callback', $field )
90 94 && ! empty( $field['callback'] )
91 95 ) {
@@ -161,10 +165,10 @@
161 165
162 166 case 'text':
163 167 case 'text-medium':
164 168 case 'text_medium':
165 - case 'text-small' :
166 - case 'text_small' :
169 + case 'text-small':
170 + case 'text_small':
167 171 // CMB2 compatibility: Set field type to text.
168 172 $field['type'] = isset( $field['attributes']['type'] ) ? $field['attributes']['type'] : 'text';
169 173
170 174 // CMB2 compatibility: Set data type to price.
@@ -183,9 +187,9 @@
183 187 case 'levels_id':
184 188 $field['type'] = 'hidden';
185 189 break;
186 190
187 - case 'colorpicker' :
191 + case 'colorpicker':
188 192 $field['type'] = 'text';
189 193 $field['class'] = 'give-colorpicker';
190 194 break;
191 195
@@ -190,15 +194,15 @@
190 194 break;
191 195
192 196 case 'give_default_radio_inline':
193 197 $field['type'] = 'radio';
194 - $field['options'] = array(
195 - 'default' => __( 'Default' ),
196 - );
198 + $field['options'] = [
199 + 'default' => __( 'Default', 'give' ),
200 + ];
197 201 break;
198 202
199 203 case 'donation_limit':
200 - $field['type'] = 'donation_limit';
204 + $field['type'] = 'donation_limit';
201 205 break;
202 206 } // End switch().
203 207
204 208 // CMB2 compatibility: Add support to define field description by desc & description param.
@@ -253,9 +257,9 @@
253 257 $field['after_field'] = '';
254 258 $data_type = empty( $field['data_type'] ) ? '' : $field['data_type'];
255 259
256 260 switch ( $data_type ) {
257 - case 'price' :
261 + case 'price':
258 262 $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] );
259 263
260 264 $field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' );
261 265 $field['after_field'] = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' );
@@ -260,14 +264,14 @@
260 264 $field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' );
261 265 $field['after_field'] = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' );
262 266 break;
263 267
264 - case 'decimal' :
268 + case 'decimal':
265 269 $field['attributes']['class'] .= ' give_input_decimal';
266 - $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] );
270 + $field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] );
267 271 break;
268 272
269 - default :
273 + default:
270 274 break;
271 275 }
272 276
273 277 ?>
@@ -279,9 +283,9 @@
279 283 style="<?php echo esc_attr( $field['style'] ); ?>"
280 284 name="<?php echo give_get_field_name( $field ); ?>"
281 285 id="<?php echo esc_attr( $field['id'] ); ?>"
282 286 value="<?php echo esc_attr( $field['value'] ); ?>"
283 - <?php echo give_get_custom_attributes( $field ); ?>
287 + <?php echo give_get_attribute_str( $field ); ?>
284 288 />
285 289 <?php echo $field['after_field']; ?>
286 290 <?php
287 291 echo give_get_field_description( $field );
@@ -324,23 +328,23 @@
324 328 $field['after_field'] = '';
325 329 $placeholder = isset( $field['placeholder'] ) ? 'data-placeholder="' . $field['placeholder'] . '"' : '';
326 330 $data_type = ! empty( $field['data_type'] ) ? $field['data_type'] : '';
327 331 $type = '';
328 - $allow_new_values = '';
329 - $field['value'] = give_get_field_value( $field, $thepostid );
330 - $field['value'] = is_array( $field['value'] ) ?
331 - array_fill_keys( array_filter( $field['value'] ), 'selected' ) :
332 - $field['value'];
333 - $title_prefixes_value = ( is_array( $field['value'] ) && count( $field['value'] ) > 0 ) ?
334 - array_merge( $field['options'], $field['value'] ) :
335 - $field['options'];
332 + $field['value'] = array_filter( (array) give_get_field_value( $field, $thepostid ) );
333 + $choices = $field['options'];
334 + $fieldName = esc_attr( give_get_field_name( $field ) );
335 + $allow_new_values = ! empty( $field['allow-custom-values'] ) && (bool) $field['allow-custom-values'] ? 'data-allows-new-values="true"' : '';
336 336
337 337 // Set attributes based on multiselect datatype.
338 338 if ( 'multiselect' === $data_type ) {
339 - $type = 'multiple';
340 - $allow_new_values = 'data-allows-new-values="true"';
339 + $type = 'multiple';
340 + $field['value'] = empty( $field['value'] ) ? [] : $field['value'];
341 + $fieldName .= '[]';
341 342 }
342 343
344 + if ( $allow_new_values && $field['value'] ) {
345 + $choices = array_merge( array_combine( $field['value'], $field['value'] ), $choices );
346 + }
343 347 ?>
344 348 <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
345 349 <label for="<?php echo esc_attr( give_get_field_name( $field ) ); ?>">
346 350 <?php echo wp_kses_post( $field['name'] ); ?>
@@ -348,21 +352,21 @@
348 352 <?php echo esc_attr( $field['before_field'] ); ?>
349 353 <select
350 354 class="give-select-chosen give-chosen-settings"
351 355 style="<?php echo esc_attr( $field['style'] ); ?>"
352 - name="<?php echo esc_attr( give_get_field_name( $field ) ); ?>[]"
356 + name="<?php echo $fieldName; ?>"
353 357 id="<?php echo esc_attr( $field['id'] ); ?>"
354 358 <?php echo "{$type} {$allow_new_values} {$placeholder}"; ?>
359 + <?php echo give_get_attribute_str( $field ); ?>
355 360 >
356 361 <?php
357 - if ( is_array( $title_prefixes_value ) && count( $title_prefixes_value ) > 0 ) {
358 - foreach ( $title_prefixes_value as $key => $value ) {
359 - echo sprintf(
360 - '<option %1$s value="%2$s">%2$s</option>',
361 - ( 'selected' === $value ) ? 'selected="selected"' : '',
362 - esc_attr( $key )
363 - );
364 - }
362 + foreach ( $choices as $key => $name ) {
363 + echo sprintf(
364 + '<option %1$s value="%2$s">%3$s</option>',
365 + in_array( $key, $field['value'] ) ? 'selected="selected"' : '',
366 + esc_attr( $key ),
367 + $name
368 + );
365 369 }
366 370 ?>
367 371 </select>
368 372 <?php echo esc_attr( $field['after_field'] ); ?>
@@ -371,8 +375,45 @@
371 375 <?php
372 376 }
373 377
374 378 /**
379 + * Output a label field
380 + * Note: only for internal use.
381 + *
382 + * @param array $field {
383 + * Optional. Array of text input field arguments.
384 + *
385 + * @type string $id Field ID. Default ''.
386 + * @type string $wrapper_class CSS class to use for wrapper of input field. Default ''.
387 + * @type string $value Value of input field. Default ''.
388 + * @type string $title Text to display. HTML supported Default ''.
389 + * @type string $before_field Text/HTML to add before input field. Default ''.
390 + * @type string $after_field Text/HTML to add after input field. Default ''.
391 + * }
392 + *
393 + * @since 2.7.0
394 + *
395 + * @return void
396 + */
397 +function give_label_field( $field ) {
398 + global $thepostid, $post;
399 +
400 + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
401 + $field['style'] = isset( $field['style'] ) ? $field['style'] : '';
402 + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
403 + $field['before_field'] = '';
404 + $field['after_field'] = '';
405 + ?>
406 + <p class=" <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
407 + <?php echo esc_attr( $field['before_field'] ); ?>
408 + <?php echo $field['title']; ?>
409 + <?php echo esc_attr( $field['after_field'] ); ?>
410 + <?php echo give_get_field_description( $field ); ?>
411 + </p>
412 + <?php
413 +}
414 +
415 +/**
375 416 * Give range slider field.
376 417 * Note: only for internal logic
377 418 *
378 419 * @since 2.1
@@ -403,9 +444,9 @@
403 444 // Get Give donation form ID.
404 445 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
405 446
406 447 // Default arguments.
407 - $default_options = array(
448 + $default_options = [
408 449 'style' => '',
409 450 'wrapper_class' => '',
410 451 'value' => give_get_field_value( $field, $thepostid ),
411 452 'data_type' => 'decimal',
@@ -410,19 +451,21 @@
410 451 'value' => give_get_field_value( $field, $thepostid ),
411 452 'data_type' => 'decimal',
412 453 'before_field' => '',
413 454 'after_field' => '',
414 - );
455 + ];
415 456
416 457 // Field options.
417 - $field['options'] = ! empty( $field['options'] ) ? $field['options'] : array();
458 + $field['options'] = ! empty( $field['options'] ) ? $field['options'] : [];
418 459
419 460 // Default field option arguments.
420 - $field['options'] = wp_parse_args( $field['options'], array(
461 + $field['options'] = wp_parse_args(
462 + $field['options'],
463 + [
421 464 'display_label' => '',
422 465 'minimum' => give_format_decimal( '1.00', false, false ),
423 466 'maximum' => give_format_decimal( '999999.99', false, false ),
424 - )
467 + ]
425 468 );
426 469
427 470 // Set default field options.
428 471 $field_options = wp_parse_args( $field, $default_options );
@@ -443,22 +486,26 @@
443 486 <?php
444 487 foreach ( $field_options['value'] as $amount_range => $amount_value ) {
445 488
446 489 switch ( $field_options['data_type'] ) {
447 - case 'price' :
448 - $currency_position = give_get_option( 'currency_position', 'before' );
449 - $price_field_labels = 'minimum' === $amount_range ? __( 'Minimum amount', 'give' ) : __( 'Maximum amount', 'give' );
490 + case 'price':
491 + $currency_position = give_get_option( 'currency_position', 'before' );
492 + $price_field_labels = 'minimum' === $amount_range ? __( 'Minimum amount', 'give' ) : __( 'Maximum amount', 'give' );
450 493
451 - $tooltip_html = array(
452 - 'before' => Give()->tooltips->render_span( array(
453 - 'label' => $price_field_labels,
454 - 'tag_content' => sprintf( '<span class="give-money-symbol give-money-symbol-before">%s</span>', give_currency_symbol() ),
455 - ) ),
456 - 'after' => Give()->tooltips->render_span( array(
457 - 'label' => $price_field_labels,
458 - 'tag_content' => sprintf( '<span class="give-money-symbol give-money-symbol-after">%s</span>', give_currency_symbol() ),
459 - ) ),
460 - );
494 + $tooltip_html = [
495 + 'before' => Give()->tooltips->render_span(
496 + [
497 + 'label' => $price_field_labels,
498 + 'tag_content' => sprintf( '<span class="give-money-symbol give-money-symbol-before">%s</span>', give_currency_symbol() ),
499 + ]
500 + ),
501 + 'after' => Give()->tooltips->render_span(
502 + [
503 + 'label' => $price_field_labels,
504 + 'tag_content' => sprintf( '<span class="give-money-symbol give-money-symbol-after">%s</span>', give_currency_symbol() ),
505 + ]
506 + ),
507 + ];
461 508
462 509 $before_html = ! empty( $field_options['before_field'] )
463 510 ? $field_options['before_field']
464 511 : ( 'before' === $currency_position ? $tooltip_html['before'] : '' );
@@ -466,14 +513,14 @@
466 513 $after_html = ! empty( $field_options['after_field'] )
467 514 ? $field_options['after_field']
468 515 : ( 'after' === $currency_position ? $tooltip_html['after'] : '' );
469 516
470 - $field_options['attributes']['class'] .= ' give-text_small';
517 + $field_options['attributes']['class'] .= ' give-text_small';
471 518 $field_options['value'][ $amount_range ] = $amount_value;
472 519 break;
473 520
474 - case 'decimal' :
475 - $field_options['attributes']['class'] .= ' give_input_decimal give-text_small';
521 + case 'decimal':
522 + $field_options['attributes']['class'] .= ' give_input_decimal give-text_small';
476 523 $field_options['value'][ $amount_range ] = $amount_value;
477 524 break;
478 525 }
479 526
@@ -488,9 +535,9 @@
488 535 id="<?php echo $field_options['id']; ?>_give_donation_limit_<?php echo $amount_range; ?>"
489 536 data-range_type="<?php echo esc_attr( $amount_range ); ?>"
490 537 value="<?php echo give_format_decimal( esc_attr( $field_options['value'][ $amount_range ] ) ); ?>"
491 538 placeholder="<?php echo give_format_decimal( $field_options['options'][ $amount_range ] ); ?>"
492 - <?php echo give_get_custom_attributes( $field_options ); ?>
539 + <?php echo give_get_attribute_str( $field_options ); ?>
493 540 />
494 541 <?php
495 542 echo isset( $after_html ) ? $after_html : '';
496 543 echo '</span>';
@@ -526,9 +573,9 @@
526 573 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
527 574 $field['value'] = give_get_field_value( $field, $thepostid );
528 575
529 576 // Custom attribute handling
530 - $custom_attributes = array();
577 + $custom_attributes = [];
531 578
532 579 if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) {
533 580
534 581 foreach ( $field['attributes'] as $attribute => $value ) {
@@ -541,9 +588,9 @@
541 588 type="hidden"
542 589 name="<?php echo give_get_field_name( $field ); ?>"
543 590 id="<?php echo esc_attr( $field['id'] ); ?>"
544 591 value="<?php echo esc_attr( $field['value'] ); ?>"
545 - <?php echo give_get_custom_attributes( $field ); ?>
592 + <?php echo give_get_attribute_str( $field ); ?>
546 593 />
547 594 <?php
548 595 }
549 596
@@ -574,12 +621,12 @@
574 621 $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
575 622 $field['style'] = isset( $field['style'] ) ? $field['style'] : '';
576 623 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
577 624 $field['value'] = give_get_field_value( $field, $thepostid );
578 - $default_attributes = array(
625 + $default_attributes = [
579 626 'cols' => 20,
580 - 'rows' => 10
581 - );
627 + 'rows' => 10,
628 + ];
582 629 ?>
583 630 <div class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
584 631 <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
585 632 <textarea
@@ -589,9 +636,9 @@
589 636 <?php echo give_get_attribute_str( $field, $default_attributes ); ?>
590 637 ><?php echo esc_textarea( $field['value'] ); ?></textarea>
591 638 <?php
592 639 echo give_get_field_description( $field );
593 - echo '</div>';
640 + echo '</div>';
594 641 }
595 642
596 643 /**
597 644 * Output a wysiwyg.
@@ -620,21 +667,29 @@
620 667 $field['value'] = give_get_field_value( $field, $thepostid );
621 668 $field['style'] = isset( $field['style'] ) ? $field['style'] : '';
622 669 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
623 670
624 - $field['unique_field_id'] = give_get_field_name( $field );
625 - $editor_attributes = array(
671 + // Since WP 3.9.0 WP does not allow square brackets in field id.
672 + // If we pass square brackets in field id then code will work as expected but you will get PHP warnings.
673 + // wp-includes/class-wp-editor.php::parse_settings::106
674 + $field['unique_field_id'] = str_replace( [ '[', ']' ], [ '_', '' ], give_get_field_name( $field ) );
675 +
676 + $editor_attributes = [
626 677 'textarea_name' => isset( $field['repeatable_field_id'] ) ? $field['repeatable_field_id'] : $field['id'],
627 678 'textarea_rows' => '10',
628 679 'editor_css' => esc_attr( $field['style'] ),
629 680 'editor_class' => $field['attributes']['class'],
630 - );
631 - $data_wp_editor = ' data-wp-editor="' . base64_encode( json_encode( array(
632 - $field['value'],
633 - $field['unique_field_id'],
634 - $editor_attributes,
635 - ) ) ) . '"';
636 - $data_wp_editor = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : '';
681 + ];
682 + $data_wp_editor = ' data-wp-editor="' . base64_encode(
683 + json_encode(
684 + [
685 + $field['value'],
686 + $field['unique_field_id'],
687 + $editor_attributes,
688 + ]
689 + )
690 + ) . '"';
691 + $data_wp_editor = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : '';
637 692
638 693 echo '<div class="give-field-wrap ' . $field['unique_field_id'] . '_field ' . esc_attr( $field['wrapper_class'] ) . '"' . $data_wp_editor . '><label for="' . $field['unique_field_id'] . '">' . wp_kses_post( $field['name'] ) . '</label>';
639 694
640 695 wp_editor(
@@ -686,9 +741,9 @@
686 741 name="<?php echo give_get_field_name( $field ); ?>"
687 742 id="<?php echo esc_attr( $field['id'] ); ?>"
688 743 value="<?php echo esc_attr( $field['cbvalue'] ); ?>"
689 744 <?php echo checked( $field['value'], $field['cbvalue'], false ); ?>
690 - <?php echo give_get_custom_attributes( $field ); ?>
745 + <?php echo give_get_attribute_str( $field ); ?>
691 746 />
692 747 <?php
693 748 echo give_get_field_description( $field );
694 749 echo '</p>';
@@ -694,8 +749,70 @@
694 749 echo '</p>';
695 750 }
696 751
697 752 /**
753 + * Output multi checkbox input box.
754 + *
755 + * @since 2.9.0
756 + *
757 + * @param array $field {
758 + * Optional. Array of checkbox field arguments.
759 + *
760 + * @type string $id Field ID. Default ''.
761 + * @type string $style CSS style for input field. Default ''.
762 + * @type string $wrapper_class CSS class to use for wrapper of input field. Default ''.
763 + * @type string $value Value of input field. Default ''.
764 + * @type string $name Name of input field. Default ''.
765 + * @type string $description Description of input field. Default ''.
766 + * @type array $attributes List of attributes of input field. Default array().
767 + * for example: 'attributes' => array( 'placeholder' => '*****', 'class'
768 + * => '****' )
769 + * @type array $options List of options. Default array().
770 + * for example: 'options' => array( 'option1' => 'Option 1', 'option2' =>
771 + * 'Option 2' )
772 + * }
773 + * @return void
774 + */
775 +function give_multicheck( $field ) {
776 + global $thepostid, $post;
777 +
778 + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
779 + $field['style'] = isset( $field['style'] ) ? $field['style'] : '';
780 + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
781 + $field['value'] = give_get_field_value( $field, $thepostid );
782 + $field['value'] = is_array( $field['value'] ) ? $field['value'] : [];
783 + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
784 +
785 + ?>
786 + <fieldset class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
787 + <span class="give-field-label"><?php echo wp_kses_post( $field['name'] ); ?></span>
788 + <legend class="screen-reader-text"><?php echo wp_kses_post( $field['name'] ); ?></legend>
789 +
790 + <ul>
791 + <?php foreach ( $field['options'] as $key => $value ) : ?>
792 + <li>
793 + <label>
794 + <input
795 + type="checkbox"
796 + name="<?php echo give_get_field_name( $field ); ?>[]"
797 + value="<?php echo esc_attr( $key ); ?>"
798 + style="<?php echo esc_attr( $field['style'] ); ?>"
799 + <?php echo give_get_attribute_str( $field ); ?>
800 + <?php
801 + if ( in_array( $key, $field['value'] ) ) {
802 + echo 'checked="checked"';}
803 + ?>
804 + /> <?php echo esc_html( $value ); ?>
805 + </label>
806 + </li>
807 + <?php endforeach; ?>
808 + </ul>
809 + <?php echo give_get_field_description( $field ); ?>
810 + </fieldset>
811 + <?php
812 +}
813 +
814 +/**
698 815 * Output a select input box.
699 816 *
700 817 * @since 1.8
701 818 *
@@ -729,10 +846,10 @@
729 846 <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
730 847 <select
731 848 id="<?php echo esc_attr( $field['id'] ); ?>"
732 849 name="<?php echo give_get_field_name( $field ); ?>"
733 - style="<?php echo esc_attr( $field['style'] ) ?>"
734 - <?php echo give_get_custom_attributes( $field ); ?>
850 + style="<?php echo esc_attr( $field['style'] ); ?>"
851 + <?php echo give_get_attribute_str( $field ); ?>
735 852 >
736 853 <?php
737 854 foreach ( $field['options'] as $key => $value ) {
738 855 echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
@@ -783,9 +900,9 @@
783 900 value="' . esc_attr( $key ) . '"
784 901 type="radio"
785 902 style="' . esc_attr( $field['style'] ) . '"
786 903 ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' '
787 - . give_get_custom_attributes( $field ) . '
904 + . give_get_attribute_str( $field ) . '
788 905 /> ' . esc_html( $value ) . '</label>
789 906 </li>';
790 907 }
791 908 echo '</ul>';
@@ -794,8 +911,71 @@
794 911 echo '</fieldset>';
795 912 }
796 913
797 914 /**
915 + * Output a multi-line radio input box.
916 + *
917 + * @since 2.9.0
918 + *
919 + * @param array $field {
920 + * Optional. Array of radio field arguments.
921 + *
922 + * @type string $id Field ID. Default ''.
923 + * @type string $style CSS style for input field. Default ''.
924 + * @type string $wrapper_class CSS class to use for wrapper of input field. Default ''.
925 + * @type string $value Value of input field. Default ''.
926 + * @type string $name Name of input field. Default ''.
927 + * @type string $description Description of input field. Default ''.
928 + * @type array $attributes List of attributes of input field. Default array().
929 + * for example: 'attributes' => array( 'placeholder' => '*****', 'class'
930 + * => '****' )
931 + * @type array $options List of options. Default array().
932 + * for example: 'options' => array( 'enable' => [ 'label' => 'Enable', 'description' => 'Description' ] )
933 + * }
934 + * @return void
935 + */
936 +function give_multiradio( $field ) {
937 + global $thepostid, $post;
938 +
939 + $thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
940 + $field['style'] = isset( $field['style'] ) ? $field['style'] : '';
941 + $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
942 + $field['value'] = give_get_field_value( $field, $thepostid );
943 + $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
944 + ?>
945 +
946 + <fieldset class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
947 + <span class="give-field-label"><?php echo wp_kses_post( $field['name'] ); ?></span>
948 + <legend class="screen-reader-text"><?php echo wp_kses_post( $field['name'] ); ?></legend>
949 +
950 +
951 + <ul class="give-radios">
952 + <?php foreach ( $field['options'] as $key => $data ) : ?>
953 + <li>
954 + <label>
955 + <input
956 + type="radio"
957 + name="<?php echo give_get_field_name( $field ); ?>"
958 + value="<?php echo esc_attr( $key ); ?>"
959 + style="<?php echo esc_attr( $field['style'] ); ?>"
960 + <?php echo checked( esc_attr( $field['value'] ), esc_attr( $key ), false ); ?>
961 + <?php echo give_get_attribute_str( $field ); ?>
962 + /> <?php echo esc_html( $data['label'] ); ?>
963 + </label>
964 + <?php if ( isset( $data['description'] ) ) : ?>
965 + <span class="give-field-description">
966 + <?php echo wp_kses_post( $data['description'] ); ?>
967 + </span>
968 + <?php endif; ?>
969 + </li>
970 + <?php endforeach; ?>
971 + </ul>
972 + <?php echo give_get_field_description( $field ); ?>
973 + </fieldset>
974 + <?php
975 +}
976 +
977 +/**
798 978 * Output a colorpicker.
799 979 *
800 980 * @since 1.8
801 981 *
@@ -826,13 +1006,14 @@
826 1006 ?>
827 1007 <p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
828 1008 <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
829 1009 <input
830 - type="<?php echo esc_attr( $field['type'] ); ?>"
831 - style="<?php echo esc_attr( $field['style'] ); ?>"
832 - name="<?php echo give_get_field_name( $field ); ?>"
833 - id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr( $field['value'] ); ?>"
834 - <?php echo give_get_custom_attributes( $field ); ?>
1010 + type="<?php echo esc_attr( $field['type'] ); ?>"
1011 + style="<?php echo esc_attr( $field['style'] ); ?>"
1012 + name="<?php echo give_get_field_name( $field ); ?>"
1013 + id="<?php echo esc_attr( $field['id'] ); ?>"
1014 + value="<?php echo esc_attr( $field['value'] ); ?>"
1015 + <?php echo give_get_attribute_str( $field ); ?>
835 1016 />
836 1017 <?php
837 1018 echo give_get_field_description( $field );
838 1019 echo '</p>';
@@ -871,15 +1052,15 @@
871 1052
872 1053 // Allow developer to save attachment ID or attachment url as metadata.
873 1054 $field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url';
874 1055
875 - $allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' );
1056 + $allow_media_preview_tags = [ 'jpg', 'jpeg', 'png', 'gif', 'ico' ];
876 1057 $preview_image_src = $field['value'] ? ( 'id' === $field['fvalue'] ? wp_get_attachment_url( $field['value'] ) : $field['value'] ) : '#';
877 1058 $preview_image_extension = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : '';
878 1059 $is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags );
879 1060 ?>
880 1061 <fieldset class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
881 - <label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
1062 + <label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
882 1063 <input
883 1064 name="<?php echo give_get_field_name( $field ); ?>"
884 1065 id="<?php echo esc_attr( $field['id'] ); ?>"
885 1066 type="text"
@@ -884,9 +1065,9 @@
884 1065 id="<?php echo esc_attr( $field['id'] ); ?>"
885 1066 type="text"
886 1067 value="<?php echo $field['value']; ?>"
887 1068 style="<?php echo esc_attr( $field['style'] ); ?>"
888 - <?php echo give_get_custom_attributes( $field ); ?>
1069 + <?php echo give_get_attribute_str( $field ); ?>
889 1070 />&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button" value="<?php echo $button_label; ?>" data-fvalue="<?php echo $field['fvalue']; ?>" data-field-type="<?php echo $field['type']; ?>">
890 1071 <?php echo give_get_field_description( $field ); ?>
891 1072 <div class="give-image-thumb<?php echo ! $field['value'] || ! $is_show_preview ? ' give-hidden' : ''; ?>">
892 1073 <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span>
@@ -909,9 +1090,9 @@
909 1090 global $thepostid, $post;
910 1091
911 1092 // get all active payment gateways.
912 1093 $gateways = give_get_enabled_payment_gateways( $thepostid );
913 - $field['options'] = array();
1094 + $field['options'] = [];
914 1095
915 1096 // Set field option value.
916 1097 if ( ! empty( $gateways ) ) {
917 1098 foreach ( $gateways as $key => $option ) {
@@ -920,9 +1101,9 @@
920 1101 }
921 1102
922 1103 // Add a field to the Give Form admin single post view of this field
923 1104 if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
924 - $field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] );
1105 + $field['options'] = array_merge( [ 'global' => esc_html__( 'Global Default', 'give' ) ], $field['options'] );
925 1106 }
926 1107
927 1108 // Render select field.
928 1109 give_select( $field );
@@ -951,11 +1132,11 @@
951 1132 $field['url'] = isset( $field['url'] ) ? $field['url'] : 'https://givewp.com/documentation';
952 1133 $field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation';
953 1134
954 1135 echo '<p class="give-docs-link"><a href="' . esc_url( $field['url'] )
955 - . '" target="_blank">'
956 - . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] )
957 - . '<span class="dashicons dashicons-editor-help"></span></a></p>';
1136 + . '" target="_blank">'
1137 + . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] )
1138 + . '<span class="dashicons dashicons-editor-help"></span></a></p>';
958 1139 }
959 1140
960 1141
961 1142 /**
@@ -968,9 +1149,9 @@
968 1149 function give_email_preview_buttons( $field ) {
969 1150 /* @var WP_Post $post */
970 1151 global $post;
971 1152
972 - $field_id = str_replace( array( '_give_', '_preview_buttons' ), '', $field['id'] );
1153 + $field_id = str_replace( [ '_give_', '_preview_buttons' ], '', $field['id'] );
973 1154
974 1155 ob_start();
975 1156
976 1157 echo '<p class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field"><label for="' . give_get_field_name( $field ) . '">' . wp_kses_post( $field['name'] ) . '</label>';
@@ -976,32 +1157,39 @@
976 1157 echo '<p class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field"><label for="' . give_get_field_name( $field ) . '">' . wp_kses_post( $field['name'] ) . '</label>';
977 1158
978 1159 echo sprintf(
979 1160 '<a href="%1$s" class="button-secondary" target="_blank">%2$s</a>',
980 - wp_nonce_url(
981 - add_query_arg(
982 - array(
983 - 'give_action' => 'preview_email',
984 - 'email_type' => $field_id,
985 - 'form_id' => $post->ID,
986 - ),
987 - home_url()
988 - ), 'give-preview-email'
989 - ),
1161 + esc_url(
1162 + wp_nonce_url(
1163 + add_query_arg(
1164 + [
1165 + 'give_action' => 'preview_email',
1166 + 'email_type' => $field_id,
1167 + 'form_id' => $post->ID,
1168 + ],
1169 + home_url()
1170 + ),
1171 + 'give-preview-email'
1172 + )
1173 + ),
990 1174 $field['name']
991 1175 );
992 1176
993 1177 echo sprintf(
994 1178 ' <a href="%1$s" aria-label="%2$s" class="button-secondary">%3$s</a>',
995 - wp_nonce_url(
996 - add_query_arg(
997 - array(
998 - 'give_action' => 'send_preview_email',
999 - 'email_type' => $field_id,
1000 - 'give-messages[]' => 'sent-test-email',
1001 - 'form_id' => $post->ID,
1002 - )
1003 - ), 'give-send-preview-email' ),
1179 + esc_url(
1180 + wp_nonce_url(
1181 + add_query_arg(
1182 + [
1183 + 'give_action' => 'send_preview_email',
1184 + 'email_type' => $field_id,
1185 + 'give-messages[]' => 'sent-test-email',
1186 + 'form_id' => $post->ID,
1187 + ]
1188 + ),
1189 + 'give-send-preview-email'
1190 + )
1191 + ),
1004 1192 esc_attr__( 'Send Test Email.', 'give' ),
1005 1193 esc_html__( 'Send Test Email', 'give' )
1006 1194 );
1007 1195
@@ -1042,12 +1230,12 @@
1042 1230 if ( '_give_custom_amount_range' === $field['id'] && empty( $minimum ) ) {
1043 1231 $minimum = give_get_meta( $postid, '_give_custom_amount_minimum', true );
1044 1232 }
1045 1233
1046 - $field_value = array(
1234 + $field_value = [
1047 1235 'minimum' => $minimum,
1048 1236 'maximum' => give_get_meta( $postid, $field['id'] . '_maximum', true ),
1049 - );
1237 + ];
1050 1238 } else {
1051 1239 // Get value from db.
1052 1240 $field_value = give_get_meta( $postid, $field['id'], true );
1053 1241 }
@@ -1225,9 +1413,9 @@
1225 1413 $close_tabs = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0;
1226 1414 $wrapper_class = isset( $fields['wrapper_class'] ) ? $fields['wrapper_class'] : '';
1227 1415 ?>
1228 1416 <div class="give-repeatable-field-section <?php echo esc_attr( $wrapper_class ); ?>" id="<?php echo "{$fields['id']}_field"; ?>"
1229 - data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>">
1417 + data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>">
1230 1418 <?php if ( ! empty( $fields['name'] ) ) : ?>
1231 1419 <p class="give-repeater-field-name"><?php echo $fields['name']; ?></p>
1232 1420 <?php endif; ?>
1233 1421
@@ -1236,10 +1424,19 @@
1236 1424 <?php endif; ?>
1237 1425
1238 1426 <table class="give-repeatable-fields-section-wrapper" cellspacing="0">
1239 1427 <?php
1240 - $repeater_field_values = give_get_meta( $thepostid, $fields['id'], true );
1241 - $header_title = isset( $fields['options']['header_title'] )
1428 + // Get value.
1429 + $repeater_field_values = ! empty( $fields['attributes']['value'] )
1430 + ? $fields['attributes']['value']
1431 + : give_get_meta( $thepostid, $fields['id'], true );
1432 +
1433 + // Setup default value.
1434 + if ( empty( $repeater_field_values ) && ! empty( $fields['default'] ) ) {
1435 + $repeater_field_values = $fields['default'];
1436 + }
1437 +
1438 + $header_title = isset( $fields['options']['header_title'] )
1242 1439 ? $fields['options']['header_title']
1243 1440 : esc_attr__( 'Group', 'give' );
1244 1441
1245 1442 $add_default_donation_field = false;
@@ -1256,9 +1453,9 @@
1256 1453 <!--Repeater field group template-->
1257 1454 <tr class="give-template give-row">
1258 1455 <td class="give-repeater-field-wrap give-column" colspan="2">
1259 1456 <div class="give-row-head give-move">
1260 - <button type="button" class="handlediv button-link"><span class="toggle-indicator"></span>
1457 + <button type="button" class="give-handlediv button-link"><span class="toggle-indicator"></span>
1261 1458 </button>
1262 1459 <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span>
1263 1460 <h2>
1264 1461 <span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
@@ -1274,10 +1471,10 @@
1274 1471 <?php
1275 1472 $field['repeat'] = true;
1276 1473 $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields );
1277 1474 $field['id'] = str_replace(
1278 - array( '[', ']' ),
1279 - array( '_', '', ),
1475 + [ '[', ']' ],
1476 + [ '_', '' ],
1280 1477 $field['repeatable_field_id']
1281 1478 );
1282 1479 ?>
1283 1480 <?php give_render_field( $field ); ?>
@@ -1291,9 +1488,9 @@
1291 1488 <?php foreach ( $repeater_field_values as $index => $field_group ) : ?>
1292 1489 <tr class="give-row">
1293 1490 <td class="give-repeater-field-wrap give-column" colspan="2">
1294 1491 <div class="give-row-head give-move">
1295 - <button type="button" class="handlediv button-link">
1492 + <button type="button" class="give-handlediv button-link">
1296 1493 <span class="toggle-indicator"></span></button>
1297 1494 <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-
1298 1495 </span>
1299 1496 <h2>
@@ -1301,18 +1498,20 @@
1301 1498 </h2>
1302 1499 </div>
1303 1500 <div class="give-row-body">
1304 1501 <?php foreach ( $fields['fields'] as $field ) : ?>
1305 - <?php if ( ! give_is_field_callback_exist( $field ) ) {
1502 + <?php
1503 + if ( ! give_is_field_callback_exist( $field ) ) {
1306 1504 continue;
1307 - } ?>
1505 + }
1506 + ?>
1308 1507 <?php
1309 1508 $field['repeat'] = true;
1310 1509 $field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index );
1311 1510 $field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields );
1312 1511 $field['id'] = str_replace(
1313 - array( '[', ']' ),
1314 - array( '_', '', ),
1512 + [ '[', ']' ],
1513 + [ '_', '' ],
1315 1514 $field['repeatable_field_id']
1316 1515 );
1317 1516 ?>
1318 1517 <?php give_render_field( $field ); ?>
@@ -1319,9 +1518,11 @@
1319 1518 <?php endforeach; ?>
1320 1519 </div>
1321 1520 </td>
1322 1521 </tr>
1323 - <?php endforeach;; ?>
1522 + <?php
1523 + endforeach;
1524 + ?>
1324 1525
1325 1526 <?php elseif ( $add_default_donation_field ) : ?>
1326 1527 <!--Default repeater field group-->
1327 1528 <tr class="give-row">
@@ -1326,9 +1527,9 @@
1326 1527 <!--Default repeater field group-->
1327 1528 <tr class="give-row">
1328 1529 <td class="give-repeater-field-wrap give-column" colspan="2">
1329 1530 <div class="give-row-head give-move">
1330 - <button type="button" class="handlediv button-link">
1531 + <button type="button" class="give-handlediv button-link">
1331 1532 <span class="toggle-indicator"></span></button>
1332 1533 <span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-
1333 1534 </span>
1334 1535 <h2>
@@ -1350,10 +1551,10 @@
1350 1551 $field,
1351 1552 $fields
1352 1553 );
1353 1554 $field['id'] = str_replace(
1354 - array( '[', ']' ),
1355 - array( '_', '', ),
1555 + [ '[', ']' ],
1556 + [ '_', '' ],
1356 1557 $field['repeatable_field_id']
1357 1558 );
1358 1559 give_render_field( $field );
1359 1560
@@ -1366,9 +1567,9 @@
1366 1567 </tbody>
1367 1568 <tfoot>
1368 1569 <tr>
1369 1570 <?php
1370 - $add_row_btn_title = isset( $fields['options']['add_button'] )
1571 + $add_row_btn_title = isset( $fields['options']['add_button'] )
1371 1572 ? $add_row_btn_title = $fields['options']['add_button']
1372 1573 : esc_html__( 'Add Row', 'give' );
1373 1574 ?>
1374 1575 <td colspan="2" class="give-add-repeater-field-section-row-wrap">
@@ -1382,319 +1583,8 @@
1382 1583 }
1383 1584
1384 1585
1385 1586 /**
1386 - * Get current setting tab.
1387 - *
1388 - * @since 1.8
1389 - * @return string
1390 - */
1391 -function give_get_current_setting_tab() {
1392 - // Get current setting page.
1393 - $current_setting_page = give_get_current_setting_page();
1394 -
1395 - /**
1396 - * Filter the default tab for current setting page.
1397 - *
1398 - * @since 1.8
1399 - *
1400 - * @param string
1401 - */
1402 - $default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' );
1403 -
1404 - // Get current tab.
1405 - $current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] );
1406 -
1407 - // Output.
1408 - return $current_tab;
1409 -}
1410 -
1411 -
1412 -/**
1413 - * Get current setting section.
1414 - *
1415 - * @since 1.8
1416 - * @return string
1417 - */
1418 -function give_get_current_setting_section() {
1419 - // Get current tab.
1420 - $current_tab = give_get_current_setting_tab();
1421 -
1422 - /**
1423 - * Filter the default section for current setting page tab.
1424 - *
1425 - * @since 1.8
1426 - *
1427 - * @param string
1428 - */
1429 - $default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' );
1430 -
1431 - // Get current section.
1432 - $current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] );
1433 -
1434 - // Output.
1435 - return $current_section;
1436 -}
1437 -
1438 -/**
1439 - * Get current setting page.
1440 - *
1441 - * @since 1.8
1442 - * @return string
1443 - */
1444 -function give_get_current_setting_page() {
1445 - // Get current page.
1446 - $setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : '';
1447 -
1448 - // Output.
1449 - return $setting_page;
1450 -}
1451 -
1452 -/**
1453 - * Set value for Form content --> Display content field setting.
1454 - *
1455 - * Backward compatibility: set value by _give_content_option form meta field value if _give_display_content is not set
1456 - * yet.
1457 - *
1458 - * @since 1.8
1459 - *
1460 - * @param mixed $field_value Field Value.
1461 - * @param array $field Field args.
1462 - * @param int $postid Form/Post ID.
1463 - *
1464 - * @return string
1465 - */
1466 -function _give_display_content_field_value( $field_value, $field, $postid ) {
1467 - $show_content = give_get_meta( $postid, '_give_content_option', true );
1468 -
1469 - if (
1470 - ! give_get_meta( $postid, '_give_display_content', true )
1471 - && $show_content
1472 - && ( 'none' !== $show_content )
1473 - ) {
1474 - $field_value = 'enabled';
1475 - }
1476 -
1477 - return $field_value;
1478 -}
1479 -
1480 -add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 );
1481 -
1482 -
1483 -/**
1484 - * Set value for Form content --> Content placement field setting.
1485 - *
1486 - * Backward compatibility: set value by _give_content_option form meta field value if _give_content_placement is not
1487 - * set yet.
1488 - *
1489 - * @since 1.8
1490 - *
1491 - * @param mixed $field_value Field Value.
1492 - * @param array $field Field args.
1493 - * @param int $postid Form/Post ID.
1494 - *
1495 - * @return string
1496 - */
1497 -function _give_content_placement_field_value( $field_value, $field, $postid ) {
1498 - $show_content = give_get_meta( $postid, '_give_content_option', true );
1499 -
1500 - if (
1501 - ! give_get_meta( $postid, '_give_content_placement', true )
1502 - && ( 'none' !== $show_content )
1503 - ) {
1504 - $field_value = $show_content;
1505 - }
1506 -
1507 - return $field_value;
1508 -}
1509 -
1510 -add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 );
1511 -
1512 -
1513 -/**
1514 - * Set value for Terms and Conditions --> Terms and Conditions field setting.
1515 - *
1516 - * Backward compatibility: set value by _give_terms_option form meta field value if it's value is none.
1517 - *
1518 - * @since 1.8
1519 - *
1520 - * @param mixed $field_value Field Value.
1521 - * @param array $field Field args.
1522 - * @param int $postid Form/Post ID.
1523 - *
1524 - * @return string
1525 - */
1526 -function _give_terms_option_field_value( $field_value, $field, $postid ) {
1527 - $term_option = give_get_meta( $postid, '_give_terms_option', true );
1528 -
1529 - if ( in_array( $term_option, array( 'none', 'yes' ) ) ) {
1530 - $field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' );
1531 - }
1532 -
1533 - return $field_value;
1534 -}
1535 -
1536 -add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 );
1537 -
1538 -
1539 -/**
1540 - * Set value for Form Display --> Offline Donation --> Billing Fields.
1541 - *
1542 - * Backward compatibility: set value by _give_offline_donation_enable_billing_fields_single form meta field value if
1543 - * it's value is on.
1544 - *
1545 - * @since 1.8
1546 - *
1547 - * @param mixed $field_value Field Value.
1548 - * @param array $field Field args.
1549 - * @param int $postid Form/Post ID.
1550 - *
1551 - * @return string
1552 - */
1553 -function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) {
1554 - $offline_donation = give_get_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true );
1555 -
1556 - if ( 'on' === $offline_donation ) {
1557 - $field_value = 'enabled';
1558 - }
1559 -
1560 - return $field_value;
1561 -}
1562 -
1563 -add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 );
1564 -
1565 -
1566 -/**
1567 - * Set value for Donation Options --> Custom Amount.
1568 - *
1569 - * Backward compatibility: set value by _give_custom_amount form meta field value if it's value is yes or no.
1570 - *
1571 - * @since 1.8
1572 - *
1573 - * @param mixed $field_value Field Value.
1574 - * @param array $field Field args.
1575 - * @param int $postid Form/Post ID.
1576 - *
1577 - * @return string
1578 - */
1579 -function _give_custom_amount_field_value( $field_value, $field, $postid ) {
1580 - $custom_amount = give_get_meta( $postid, '_give_custom_amount', true );
1581 -
1582 - if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) {
1583 - $field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' );
1584 - }
1585 -
1586 - return $field_value;
1587 -}
1588 -
1589 -add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 );
1590 -
1591 -
1592 -/**
1593 - * Set value for Donation Goal --> Donation Goal.
1594 - *
1595 - * Backward compatibility: set value by _give_goal_option form meta field value if it's value is yes or no.
1596 - *
1597 - * @since 1.8
1598 - *
1599 - * @param mixed $field_value Field Value.
1600 - * @param array $field Field args.
1601 - * @param int $postid Form/Post ID.
1602 - *
1603 - * @return string
1604 - */
1605 -function _give_goal_option_field_value( $field_value, $field, $postid ) {
1606 - $goal_option = give_get_meta( $postid, '_give_goal_option', true );
1607 -
1608 - if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) {
1609 - $field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' );
1610 - }
1611 -
1612 - return $field_value;
1613 -}
1614 -
1615 -add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 );
1616 -
1617 -/**
1618 - * Set value for Donation Goal --> close Form.
1619 - *
1620 - * Backward compatibility: set value by _give_close_form_when_goal_achieved form meta field value if it's value is yes
1621 - * or no.
1622 - *
1623 - * @since 1.8
1624 - *
1625 - * @param mixed $field_value Field Value.
1626 - * @param array $field Field args.
1627 - * @param int $postid Form/Post ID.
1628 - *
1629 - * @return string
1630 - */
1631 -function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) {
1632 - $close_form = give_get_meta( $postid, '_give_close_form_when_goal_achieved', true );
1633 -
1634 - if ( in_array( $close_form, array( 'yes', 'no' ) ) ) {
1635 - $field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' );
1636 - }
1637 -
1638 - return $field_value;
1639 -}
1640 -
1641 -add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 );
1642 -
1643 -
1644 -/**
1645 - * Set value for Form display --> Guest Donation.
1646 - *
1647 - * Backward compatibility: set value by _give_logged_in_only form meta field value if it's value is yes or no.
1648 - *
1649 - * @since 1.8
1650 - *
1651 - * @param mixed $field_value Field Value.
1652 - * @param array $field Field args.
1653 - * @param int $postid Form/Post ID.
1654 - *
1655 - * @return string
1656 - */
1657 -function _give_logged_in_only_value( $field_value, $field, $postid ) {
1658 - $guest_donation = give_get_meta( $postid, '_give_logged_in_only', true );
1659 -
1660 - if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) {
1661 - $field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' );
1662 - }
1663 -
1664 - return $field_value;
1665 -}
1666 -
1667 -add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 );
1668 -
1669 -/**
1670 - * Set value for Offline Donations --> Offline Donations.
1671 - *
1672 - * Backward compatibility: set value by _give_customize_offline_donations form meta field value if it's value is yes
1673 - * or no.
1674 - *
1675 - * @since 1.8
1676 - *
1677 - * @param mixed $field_value Field Value.
1678 - * @param array $field Field args.
1679 - * @param int $postid Form/Post ID.
1680 - *
1681 - * @return string
1682 - */
1683 -function _give_customize_offline_donations_value( $field_value, $field, $postid ) {
1684 - $customize_offline_text = give_get_meta( $postid, '_give_customize_offline_donations', true );
1685 -
1686 - if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) {
1687 - $field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' );
1688 - }
1689 -
1690 - return $field_value;
1691 -}
1692 -
1693 -add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 );
1694 -
1695 -
1696 -/**
1697 1587 * Set repeater field id for multi donation form.
1698 1588 *
1699 1589 * @since 1.8
1700 1590 *
@@ -1815,9 +1705,8 @@
1815 1705 $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
1816 1706 $field['value'] = give_get_field_value( $field, $thepostid );
1817 1707 $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id'];
1818 1708
1819 -
1820 1709 printf(
1821 1710 '<fieldset class="give-field-wrap %s_field %s">',
1822 1711 esc_attr( $field['id'] ),
1823 1712 esc_attr( $field['wrapper_class'] )
@@ -1833,9 +1722,9 @@
1833 1722 esc_html( $field['name'] )
1834 1723 );
1835 1724 ?>
1836 1725
1837 - <ul class="give-radios">
1726 + <ul class="give-radios">
1838 1727 <?php
1839 1728 foreach ( $field['options'] as $key => $value ) {
1840 1729 $attributes = empty( $field['attributes'] ) ? '' : give_get_attribute_str( $field['attributes'] );
1841 1730 printf(
@@ -1848,9 +1737,9 @@
1848 1737 esc_html( $value )
1849 1738 );
1850 1739 }
1851 1740 ?>
1852 - </ul>
1741 + </ul>
1853 1742
1854 1743 <?php
1855 1744 /**
1856 1745 * Action to add HTML after donation form radio button is display and before description.