PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13.1
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13.1
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
← All changes | templates/form-fields/select.php +68 -28 1.6.7 → 1.8.13.1 View file →
@@ -1,12 +1,20 @@
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 select 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.8.6
16 + * @version 1.8.13.1
9 17 */
10 18
11 19 if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) {
12 20 return;
@@ -11,44 +19,73 @@
11 19 if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) {
12 20 return;
13 21 }
14 22
15 -$form = $view_args['form'];
16 -$field = $view_args['field'];
17 -$classes = $view_args['classes'];
18 -$is_required = isset( $field['required'] ) ? $field['required'] : false;
19 -$options = isset( $field['options'] ) ? $field['options'] : array();
20 -$value = isset( $field['value'] ) ? $field['value'] : '';
23 +$charitable_form = $view_args['form'];
24 +$charitable_field = $view_args['field'];
25 +$charitable_classes = $view_args['classes'];
26 +$charitable_is_required = isset( $charitable_field['required'] ) ? $charitable_field['required'] : false;
27 +$charitable_options = isset( $charitable_field['options'] ) ? $charitable_field['options'] : array();
28 +$charitable_value = isset( $charitable_field['value'] ) ? $charitable_field['value'] : '';
21 29
22 -if ( is_array( $value ) ) {
23 - $value = current( $value );
30 +if ( is_array( $charitable_value ) ) {
31 + $charitable_value = current( $charitable_value );
24 32 }
25 33
26 -if ( count( $options ) ) :
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 +}
27 44
28 -?>
29 -<div id="charitable_field_<?php echo $field['key'] ?>" class="<?php echo esc_attr( $classes ) ?>">
30 - <?php if ( isset( $field['label'] ) ) : ?>
31 - <label for="charitable_field_<?php echo esc_attr( $field['key'] ) ?>_element">
32 - <?php echo $field['label'] ?>
33 - <?php if ( $is_required ) : ?>
34 - <abbr class="required" title="required">*</abbr>
45 +if ( count( $charitable_options ) ) :
46 +
47 + ?>
48 +<div id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>" class="<?php echo esc_attr( $charitable_classes ); ?>">
49 + <?php if ( isset( $charitable_field['label'] ) ) : ?>
50 + <label for="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element">
51 + <?php echo wp_kses_post( $charitable_field['label'] ); ?>
52 + <?php if ( $charitable_is_required ) : ?>
53 + <abbr class="required" title="<?php esc_html_e( 'Required', 'charitable' ); ?>">*</abbr>
35 54 <?php endif ?>
36 55 </label>
37 56 <?php endif ?>
38 - <select name="<?php echo $field['key'] ?>" id="charitable_field_<?php echo esc_attr( $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. ?>>
39 75 <?php
40 - foreach ( $options as $val => $label ) :
76 + foreach ( $charitable_options as $charitable_val => $charitable_label ) :
41 77
42 - if ( is_array( $label ) ) : ?>
43 - <optgroup label="<?php echo esc_attr( $val ) ?>">
44 - <?php foreach ( $label as $val => $label ) : ?>
45 - <option value="<?php echo esc_attr( $val ) ?>" <?php selected( $val, $value ) ?>><?php echo $label ?></option>
46 - <?php endforeach; ?>
47 - </optgroup>
78 + if ( is_array( $charitable_label ) ) :
79 + ?>
80 + <optgroup label="<?php echo esc_attr( $charitable_val ); ?>">
81 + <?php foreach ( $charitable_label as $charitable_val => $charitable_label ) : ?>
82 + <option value="<?php echo esc_attr( $charitable_val ); ?>" <?php selected( $charitable_val, $charitable_value ); ?>><?php echo esc_html( $charitable_label ); ?></option>
83 + <?php endforeach; ?>
84 + </optgroup>
48 85 <?php else : ?>
49 - <option value="<?php echo esc_attr( $val ) ?>" <?php selected( $val, $value ) ?>><?php echo $label ?></option>
50 - <?php
86 + <option value="<?php echo esc_attr( $charitable_val ); ?>" <?php selected( $charitable_val, $charitable_value ); ?>><?php echo esc_html( $charitable_label ); ?></option>
87 + <?php
51 88
52 89 endif;
53 90 endforeach;
54 91
@@ -53,8 +90,11 @@
53 90 endforeach;
54 91
55 92 ?>
56 93 </select>
94 + <?php if ( isset( $charitable_field['help'] ) ) : ?>
95 + <p class="charitable-field-help"><?php echo $charitable_field['help']; // phpcs:ignore ?></p>
96 + <?php endif ?>
57 97 </div>
58 -<?php
98 + <?php
59 99
60 100 endif;