| @@ -12,8 +12,9 @@ | ||
| 12 | 12 | * @package Charitable/Templates/Form Fields |
| 13 | 13 | * @since 1.0.0 |
| 14 | 14 | * @version 1.0.0 |
| 15 | 15 | * @version 1.8.8.6 |
| 16 | + * @version 1.8.13.1 | |
| 16 | 17 | */ |
| 17 | 18 | |
| 18 | 19 | if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) { |
| 19 | 20 | return; |
| @@ -29,8 +30,19 @@ | ||
| 29 | 30 | if ( is_array( $charitable_value ) ) { |
| 30 | 31 | $charitable_value = current( $charitable_value ); |
| 31 | 32 | } |
| 32 | 33 | |
| 34 | +/* | |
| 35 | + * Autocomplete token for known personal fields, e.g. Country (WCAG 1.3.5). 1.8.13.1 | |
| 36 | + * | |
| 37 | + * function_exists guarded for the same reason as form-fields/default.php: this template is | |
| 38 | + * theme-overridable, so a copy carried into a theme and run against an older Charitable would | |
| 39 | + * otherwise fatal. Unguarded, the select renders without the token as it did before. | |
| 40 | + */ | |
| 41 | +if ( function_exists( 'charitable_maybe_add_field_autocomplete' ) ) { | |
| 42 | + $charitable_field = charitable_maybe_add_field_autocomplete( $charitable_field ); | |
| 43 | +} | |
| 44 | + | |
| 33 | 45 | if ( count( $charitable_options ) ) : |
| 34 | 46 | |
| 35 | 47 | ?> |
| 36 | 48 | <div id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>" class="<?php echo esc_attr( $charitable_classes ); ?>"> |
| @@ -41,9 +53,26 @@ | ||
| 41 | 53 | <abbr class="required" title="<?php esc_html_e( 'Required', 'charitable' ); ?>">*</abbr> |
| 42 | 54 | <?php endif ?> |
| 43 | 55 | </label> |
| 44 | 56 | <?php endif ?> |
| 45 | - <select name="<?php echo esc_attr( $charitable_field['key'] ); ?>" id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element"> | |
| 57 | + <?php | |
| 58 | + /* | |
| 59 | + * Emit explicit attributes, as form-fields/default.php already does for text inputs | |
| 60 | + * (1.8.13.1). Without this a select could not carry an `autocomplete` token, which is | |
| 61 | + * what the Country field needs for WCAG 1.3.5 Identify Input Purpose. | |
| 62 | + * | |
| 63 | + * Deliberately passes ONLY the attrs array, rather than the whole field as default.php | |
| 64 | + * does. Handed the full field, charitable_get_arbitrary_attributes() also applies its | |
| 65 | + * back-compat pass, which would start emitting `required` on every required select -- | |
| 66 | + * a real change in browser validation behaviour, and not something an accessibility | |
| 67 | + * fix should bring in as a side effect. Same call shape as | |
| 68 | + * class-charitable-public-form-view.php. | |
| 69 | + */ | |
| 70 | + $charitable_select_attrs = charitable_get_arbitrary_attributes( | |
| 71 | + array( 'attrs' => isset( $charitable_field['attrs'] ) ? (array) $charitable_field['attrs'] : array() ) | |
| 72 | + ); | |
| 73 | + ?> | |
| 74 | + <select name="<?php echo esc_attr( $charitable_field['key'] ); ?>" id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element"<?php echo $charitable_select_attrs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- values escaped in the helper. ?>> | |
| 46 | 75 | <?php |
| 47 | 76 | foreach ( $charitable_options as $charitable_val => $charitable_label ) : |
| 48 | 77 | |
| 49 | 78 | if ( is_array( $charitable_label ) ) : |