| @@ -1,12 +1,21 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 3 | +// Exit if accessed directly. | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 2 | 8 | /** |
| 3 | 9 | * The template used to display text form fields. |
| 4 | 10 | * |
| 5 | - * @author Studio 164a | |
| 11 | + * @author WP Charitable LLC | |
| 6 | 12 | * @package Charitable/Templates/Form Fields |
| 7 | 13 | * @since 1.0.0 |
| 8 | 14 | * @version 1.0.0 |
| 15 | + * @version 1.8.6.1 Added description output. | |
| 16 | + * @version 1.8.8.6 | |
| 17 | + * @version 1.8.13.1 | |
| 9 | 18 | */ |
| 10 | 19 | |
| 11 | 20 | if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) { |
| 12 | 21 | return; |
| @@ -11,26 +20,53 @@ | ||
| 11 | 20 | if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) { |
| 12 | 21 | return; |
| 13 | 22 | } |
| 14 | 23 | |
| 15 | -$form = $view_args['form']; | |
| 16 | -$field = $view_args['field']; | |
| 17 | -$classes = esc_attr( $view_args['classes'] ); | |
| 18 | -$field_type = isset( $field['type'] ) ? $field['type'] : 'text'; | |
| 19 | -$is_required = isset( $field['required'] ) ? $field['required'] : false; | |
| 20 | -$value = isset( $field['value'] ) ? $field['value'] : ''; | |
| 24 | +$charitable_form = $view_args['form']; | |
| 25 | +$charitable_field = $view_args['field']; | |
| 26 | +$charitable_classes = esc_attr( $view_args['classes'] ); | |
| 27 | +$charitable_field_type = isset( $charitable_field['type'] ) ? $charitable_field['type'] : 'text'; | |
| 28 | +$charitable_is_required = isset( $charitable_field['required'] ) ? $charitable_field['required'] : false; | |
| 29 | +$charitable_value = isset( $charitable_field['value'] ) ? $charitable_field['value'] : ''; | |
| 21 | 30 | |
| 31 | +/* | |
| 32 | + * Fill in the autocomplete token for known personal fields (WCAG 1.3.5) -- 1.8.13.1. | |
| 33 | + * | |
| 34 | + * Done here as well as in the field registry so every render path that reaches this | |
| 35 | + * template is covered, including fields an addon registers without declaring a token. | |
| 36 | + * Never overwrites an explicit value. The attribute itself is emitted by the existing | |
| 37 | + * charitable_get_arbitrary_attributes() call on the input below. | |
| 38 | + * | |
| 39 | + * function_exists guarded because this template is theme-overridable -- | |
| 40 | + * Charitable_Template::locate_template() checks the theme and child theme before the | |
| 41 | + * plugin's own copy. A site that took a copy into its theme and later ran it against a | |
| 42 | + * Charitable without this helper (a rollback, or a theme moved between sites) would | |
| 43 | + * otherwise hit Call to undefined function on every donation form. Unguarded, the field | |
| 44 | + * simply renders without the token, exactly as it did before 1.8.13.1. | |
| 45 | + */ | |
| 46 | +if ( function_exists( 'charitable_maybe_add_field_autocomplete' ) ) { | |
| 47 | + $charitable_field = charitable_maybe_add_field_autocomplete( $charitable_field ); | |
| 48 | +} | |
| 49 | + | |
| 22 | 50 | ?> |
| 23 | -<div id="charitable_field_<?php echo $field['key'] ?>" class="<?php echo $classes ?>"> | |
| 24 | - <?php if ( isset( $field['label'] ) ) : ?> | |
| 25 | - <label for="charitable_field_<?php echo $field['key'] ?>_element"> | |
| 26 | - <?php echo $field['label'] ?> | |
| 27 | - <?php if ( $is_required ) : ?> | |
| 28 | - <abbr class="required" title="required">*</abbr> | |
| 51 | +<div id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>" class="<?php echo esc_attr( $charitable_classes ); ?>"> | |
| 52 | + <?php if ( isset( $charitable_field['label'] ) ) : ?> | |
| 53 | + <label for="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element"> | |
| 54 | + <?php echo wp_kses_post( $charitable_field['label'] ); ?> | |
| 55 | + <?php if ( $charitable_is_required ) : ?> | |
| 56 | + <abbr class="required" title="<?php esc_html_e( 'Required', 'charitable' ); ?>">*</abbr> | |
| 29 | 57 | <?php endif ?> |
| 30 | 58 | </label> |
| 31 | 59 | <?php endif ?> |
| 32 | - <?php if ( isset( $field['help'] ) ) : ?> | |
| 33 | - <p class="charitable-field-help"><?php echo $field['help'] ?></p> | |
| 60 | + <?php if ( isset( $charitable_field['help'] ) ) : ?> | |
| 61 | + <p class="charitable-field-help"><?php echo $charitable_field['help']; // phpcs:ignore ?></p> | |
| 34 | 62 | <?php endif ?> |
| 35 | - <input type="<?php echo esc_attr( $field_type ) ?>" name="<?php echo $field['key'] ?>" id="charitable_field_<?php echo $field['key'] ?>_element" value="<?php echo esc_attr( stripslashes( $value ) ) ?>" <?php echo charitable_get_arbitrary_attributes( $field ) ?>/> | |
| 63 | + <input type="<?php echo esc_attr( $charitable_field_type ); ?>" name="<?php echo esc_attr( $charitable_field['key'] ); ?>" id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element" value="<?php echo esc_attr( stripslashes( $charitable_value ) ); ?>" <?php echo charitable_get_arbitrary_attributes( $charitable_field ); // phpcs:ignore ?>/> | |
| 64 | + <?php | |
| 65 | + | |
| 66 | + // If there is a description, add it after the input. | |
| 67 | + if ( isset( $charitable_field['description'] ) && ! empty( $charitable_field['description'] ) ) { | |
| 68 | + echo '<p class="charitable-field-description">' . wp_kses_post( $charitable_field['description'] ) . '</p>'; | |
| 69 | + } | |
| 70 | + | |
| 71 | + ?> | |
| 36 | 72 | </div> |