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 / notices.php

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

68 lines 2.3 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 notices.
10 *
11 * @author WP Charitable LLC
12 * @package Charitable/Templates/Form Fields
13 * @since 1.0.0
14 * @version 1.3.0
15 * @version 1.8.8.6
16 * @version 1.8.13.1
17 */
18
19 if ( ! isset( $view_args['notices'] ) ) {
20 return;
21 }
22
23 $charitable_notices = array_filter( $view_args['notices'] );
24
25 if ( empty( $charitable_notices ) ) {
26 return;
27 }
28
29 /*
30 * Whether this render is the result of a submission (1.8.13.1).
31 *
32 * This template is generic: the same "error" bucket carries both real validation
33 * failures and page-level notices that merely use the error styling -- the
34 * admin-only "Test mode is active" notice being the one that matters, since it is
35 * present on an ordinary GET of every donation form.
36 *
37 * So role="alert" is set on every error group below (harmless either way: a live
38 * region only announces content that changes AFTER it exists, so a notice already
39 * in the page on load is not read out), but the marker that tells charitable.js it
40 * may MOVE FOCUS here is set only on a POST. Without that distinction, auto-focusing
41 * the summary would steal focus on every page load for any admin with test mode on.
42 */
43 $charitable_is_submission = isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === strtoupper( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) );
44
45 foreach ( $charitable_notices as $type => $messages ) : // phpcs:ignore
46 if ( 'error' == $type ) : // phpcs:ignore
47 $type = 'errors'; // phpcs:ignore
48 endif;
49
50 $charitable_error_attr = '';
51
52 if ( 'errors' === $type ) {
53 $charitable_error_attr = ' role="alert" tabindex="-1"';
54
55 if ( $charitable_is_submission ) {
56 $charitable_error_attr .= ' data-charitable-error-summary="1"';
57 }
58 }
59 ?>
60 <div class="charitable-notice charitable-form-<?php echo esc_attr( $type ); ?>"<?php echo $charitable_error_attr; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static attribute string built above, no user input. ?>>
61 <ul class="charitable-notice-<?php echo esc_attr( $type ); ?> <?php echo esc_attr( $type ); ?>">
62 <?php foreach ( $messages as $charitable_message ) : ?>
63 <li><?php echo $charitable_message; // phpcs:ignore ?></li>
64 <?php endforeach ?>
65 </ul><!-- charitable-notice-<?php esc_attr( $type ); ?> -->
66 </div><!-- .charitable-notices -->
67 <?php endforeach ?>
68