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
charitable / templates / form-fields / select.php

select.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13.1, at templates/form-fields/select.php

101 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * The template used to display select form fields.
10 *
11 * @author WP Charitable LLC
12 * @package Charitable/Templates/Form Fields
13 * @since 1.0.0
14 * @version 1.0.0
15 * @version 1.8.8.6
16 * @version 1.8.13.1
17 */
18
19 if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) {
20 return;
21 }
22
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'] : '';
29
30 if ( is_array( $charitable_value ) ) {
31 $charitable_value = current( $charitable_value );
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
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>
54 <?php endif ?>
55 </label>
56 <?php endif ?>
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. ?>>
75 <?php
76 foreach ( $charitable_options as $charitable_val => $charitable_label ) :
77
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>
85 <?php else : ?>
86 <option value="<?php echo esc_attr( $charitable_val ); ?>" <?php selected( $charitable_val, $charitable_value ); ?>><?php echo esc_html( $charitable_label ); ?></option>
87 <?php
88
89 endif;
90 endforeach;
91
92 ?>
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 ?>
97 </div>
98 <?php
99
100 endif;
101