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 / donation-form / donation-amount-wrapper.php

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

79 lines 3.4 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 the donation amount wrapper.
10 *
11 * @author WP Charitable LLC
12 * @package Charitable/Templates/Form Fields
13 * @since 1.5.0
14 * @version 1.8.4 // updated filtering for legend filter that was added in 1.8.3.6.
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_fields = isset( $charitable_field['fields'] ) ? $charitable_field['fields'] : array();
27 $charitable_legend = apply_filters( 'charitable_donation_amount_legend', wp_kses_post( $charitable_field['legend'] ), $charitable_form );
28
29 if ( ! count( $charitable_fields ) ) :
30 return;
31 endif;
32
33 /*
34 * Give the amount group a programmatic name (WCAG 1.3.1 Info and Relationships) -- 1.8.13.1.
35 *
36 * This is already a <fieldset>, and it already renders a visible heading, but that heading is a
37 * <div class="charitable-form-header"> rather than a <legend>, so the group had no accessible
38 * name: a screen-reader user heard each amount option but never what the group was for.
39 *
40 * Pointing aria-labelledby at the EXISTING heading rather than adding a <legend> is deliberate:
41 *
42 * - It introduces no second copy of the text, so nothing can drift between them.
43 * - <legend> carries its own hard-to-override browser layout, and this heading is a styled block
44 * in a form whose markup themes override; swapping the element risks visual regressions on
45 * every existing site for no accessibility gain over aria-labelledby.
46 * - Where the heading is absent (the legend can be filtered away), aria-label supplies a name
47 * instead, so the group is never left anonymous.
48 */
49 $charitable_has_legend = isset( $charitable_field['legend'] ) && '' !== trim( wp_strip_all_tags( (string) $charitable_legend ) );
50 $charitable_legend_id = 'charitable-donation-amount-legend-' . $charitable_form->get_form_identifier();
51
52 if ( $charitable_has_legend ) {
53 $charitable_group_attr = sprintf( ' aria-labelledby="%s"', esc_attr( $charitable_legend_id ) );
54 } else {
55 $charitable_group_attr = sprintf(
56 ' aria-label="%s"',
57 esc_attr_x( 'Select a donation amount', 'donation amount group, accessible name', 'charitable' )
58 );
59 }
60
61 ?>
62 <fieldset class="<?php echo esc_attr( $charitable_classes ); ?>"<?php echo $charitable_group_attr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above. ?>>
63 <?php
64 if ( isset( $charitable_field['legend'] ) ) :
65 ?>
66 <?php do_action( 'charitable_before_donation_amount_wrapper_header' ); ?>
67 <div class="charitable-form-header" id="<?php echo esc_attr( $charitable_legend_id ); ?>"><?php echo $charitable_legend; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
68 <?php do_action( 'charitable_after_donation_amount_wrapper_header' ); ?>
69 <?php
70 endif;
71
72 echo $charitable_form->maybe_show_current_donation_amount(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
73
74 ?>
75 <div id="charitable-donation-options-<?php echo esc_attr( $charitable_form->get_form_identifier() ); ?>">
76 <?php $charitable_form->view()->render_fields( $charitable_fields ); ?>
77 </div><!-- charitable-donation-options-<?php echo esc_attr( $charitable_form->get_form_identifier() ); ?> -->
78 </fieldset>
79