| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* The template used to display text 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.6.1 Added description output. |
| 16 |
* @version 1.8.8.6 |
| 17 |
* @version 1.8.13.1 |
| 18 |
*/ |
| 19 |
|
| 20 |
if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) { |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
$charitable_form = $view_args['form']; |
| 25 |
$charitable_field = $view_args['field']; |
| 26 |
$charitable_classes = esc_attr( $view_args['classes'] ); |
| 27 |
$charitable_field_type = isset( $charitable_field['type'] ) ? $charitable_field['type'] : 'text'; |
| 28 |
$charitable_is_required = isset( $charitable_field['required'] ) ? $charitable_field['required'] : false; |
| 29 |
$charitable_value = isset( $charitable_field['value'] ) ? $charitable_field['value'] : ''; |
| 30 |
|
| 31 |
/* |
| 32 |
* Fill in the autocomplete token for known personal fields (WCAG 1.3.5) -- 1.8.13.1. |
| 33 |
* |
| 34 |
* Done here as well as in the field registry so every render path that reaches this |
| 35 |
* template is covered, including fields an addon registers without declaring a token. |
| 36 |
* Never overwrites an explicit value. The attribute itself is emitted by the existing |
| 37 |
* charitable_get_arbitrary_attributes() call on the input below. |
| 38 |
* |
| 39 |
* function_exists guarded because this template is theme-overridable -- |
| 40 |
* Charitable_Template::locate_template() checks the theme and child theme before the |
| 41 |
* plugin's own copy. A site that took a copy into its theme and later ran it against a |
| 42 |
* Charitable without this helper (a rollback, or a theme moved between sites) would |
| 43 |
* otherwise hit Call to undefined function on every donation form. Unguarded, the field |
| 44 |
* simply renders without the token, exactly as it did before 1.8.13.1. |
| 45 |
*/ |
| 46 |
if ( function_exists( 'charitable_maybe_add_field_autocomplete' ) ) { |
| 47 |
$charitable_field = charitable_maybe_add_field_autocomplete( $charitable_field ); |
| 48 |
} |
| 49 |
|
| 50 |
?> |
| 51 |
<div id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>" class="<?php echo esc_attr( $charitable_classes ); ?>"> |
| 52 |
<?php if ( isset( $charitable_field['label'] ) ) : ?> |
| 53 |
<label for="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element"> |
| 54 |
<?php echo wp_kses_post( $charitable_field['label'] ); ?> |
| 55 |
<?php if ( $charitable_is_required ) : ?> |
| 56 |
<abbr class="required" title="<?php esc_html_e( 'Required', 'charitable' ); ?>">*</abbr> |
| 57 |
<?php endif ?> |
| 58 |
</label> |
| 59 |
<?php endif ?> |
| 60 |
<?php if ( isset( $charitable_field['help'] ) ) : ?> |
| 61 |
<p class="charitable-field-help"><?php echo $charitable_field['help']; // phpcs:ignore ?></p> |
| 62 |
<?php endif ?> |
| 63 |
<input type="<?php echo esc_attr( $charitable_field_type ); ?>" name="<?php echo esc_attr( $charitable_field['key'] ); ?>" id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element" value="<?php echo esc_attr( stripslashes( $charitable_value ) ); ?>" <?php echo charitable_get_arbitrary_attributes( $charitable_field ); // phpcs:ignore ?>/> |
| 64 |
<?php |
| 65 |
|
| 66 |
// If there is a description, add it after the input. |
| 67 |
if ( isset( $charitable_field['description'] ) && ! empty( $charitable_field['description'] ) ) { |
| 68 |
echo '<p class="charitable-field-description">' . wp_kses_post( $charitable_field['description'] ) . '</p>'; |
| 69 |
} |
| 70 |
|
| 71 |
?> |
| 72 |
</div> |
| 73 |
|