PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
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/datepicker.php +45 -29 1.7.0 → 1.8.13 View file →
@@ -1,5 +1,11 @@
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 datepicker form fields.
4 10 *
5 11 * @author WP Charitable LLC
@@ -5,8 +11,10 @@
5 11 * @author WP Charitable LLC
6 12 * @package Charitable/Templates/Form Fields
7 13 * @since 1.0.0
8 14 * @version 1.6.40
15 + * @version 1.8.6.1 Added description output.
16 + * @version 1.8.8.6
9 17 */
10 18
11 19 if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) {
12 20 return;
@@ -13,32 +21,32 @@
13 21 }
14 22
15 23 global $wp_locale;
16 24
17 -$form = $view_args['form'];
18 -$field = $view_args['field'];
19 -$classes = esc_attr( $view_args['classes'] );
20 -$is_required = isset( $field['required'] ) ? $field['required'] : false;
21 -$value = isset( $field['value'] ) ? esc_attr( $field['value'] ) : '';
22 -$min_date = isset( $field['min_date'] ) ? esc_attr( $field['min_date'] ) : '';
23 -$max_date = isset( $field['max_date'] ) ? esc_attr( $field['max_date'] ) : '';
24 -$year_range = array_key_exists( 'year_range', $field ) ? $field['year_range'] : 'c-100:c';
25 -$date_format = array_key_exists( 'date_format', $field ) ? $field['date_format'] : charitable()->registry()->get( 'i18n' )->get_js_datepicker_format( 'MM d, yy' );
26 -$json_args = array(
25 +$charitable_form = $view_args['form'];
26 +$charitable_field = $view_args['field'];
27 +$charitable_classes = esc_attr( $view_args['classes'] );
28 +$charitable_is_required = isset( $charitable_field['required'] ) ? $charitable_field['required'] : false;
29 +$charitable_value = isset( $charitable_field['value'] ) ? esc_attr( $charitable_field['value'] ) : '';
30 +$charitable_min_date = isset( $charitable_field['min_date'] ) ? esc_attr( $charitable_field['min_date'] ) : '';
31 +$charitable_max_date = isset( $charitable_field['max_date'] ) ? esc_attr( $charitable_field['max_date'] ) : '';
32 +$charitable_year_range = array_key_exists( 'year_range', $charitable_field ) ? $charitable_field['year_range'] : 'c-100:c';
33 +$charitable_date_format = array_key_exists( 'date_format', $charitable_field ) ? $charitable_field['date_format'] : charitable()->registry()->get( 'i18n' )->get_js_datepicker_format( 'MM d, yy' );
34 +$charitable_json_args = array(
27 35 'changeMonth' => true,
28 36 'changeYear' => true,
29 - 'dateFormat' => $date_format,
30 - 'yearRange' => $year_range,
37 + 'dateFormat' => $charitable_date_format,
38 + 'yearRange' => $charitable_year_range,
31 39 'monthNames' => array_values( $wp_locale->month ),
32 40 'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
33 41 );
34 42
35 -if ( array_key_exists( 'min_date', $field ) ) {
36 - $json_args['minDate'] = '+' . $field['min_date'];
43 +if ( array_key_exists( 'min_date', $charitable_field ) ) {
44 + $charitable_json_args['minDate'] = '+' . $charitable_field['min_date'];
37 45 }
38 46
39 -if ( array_key_exists( 'max_date', $field ) ) {
40 - $json_args['maxDate'] = '+' . $field['max_date'];
47 +if ( array_key_exists( 'max_date', $charitable_field ) ) {
48 + $charitable_json_args['maxDate'] = '+' . $charitable_field['max_date'];
41 49 }
42 50
43 51 /* Enqueue the datepicker */
44 52 if ( ! wp_script_is( 'jquery-ui-datepicker' ) ) {
@@ -44,24 +52,24 @@
44 52 if ( ! wp_script_is( 'jquery-ui-datepicker' ) ) {
45 53 wp_enqueue_script( 'jquery-ui-datepicker' );
46 54 }
47 55
48 -$datepicker_json_args = json_encode( $json_args );
56 +$charitable_datepicker_json_args = wp_json_encode( $charitable_json_args );
49 57
50 58 wp_add_inline_script(
51 59 'jquery-ui-datepicker',
52 - "jQuery(document).ready( function(){ jQuery( '.datepicker' ).datepicker( {$datepicker_json_args} ); });"
60 + "jQuery(document).ready( function(){ jQuery( '.datepicker' ).datepicker( {$charitable_datepicker_json_args} ); });"
53 61 );
54 62
55 63 wp_enqueue_style( 'charitable-datepicker' );
56 64
57 65 ?>
58 -<div id="charitable_field_<?php echo esc_attr( $field['key'] ); ?>" class="<?php echo $classes; ?>">
59 - <?php if ( isset( $field['label'] ) ) : ?>
60 - <label for="charitable_field_<?php echo esc_attr( $field['key'] ); ?>_element">
61 - <?php echo $field['label']; ?>
62 - <?php if ( $is_required ) : ?>
63 - <abbr class="required" title="required">*</abbr>
66 +<div id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>" class="<?php echo esc_attr( $charitable_classes ); ?>">
67 + <?php if ( isset( $charitable_field['label'] ) ) : ?>
68 + <label for="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element">
69 + <?php echo wp_kses_post( $charitable_field['label'] ); ?>
70 + <?php if ( $charitable_is_required ) : ?>
71 + <abbr class="required" title="<?php esc_html_e( 'Required', 'charitable' ); ?>">*</abbr>
64 72 <?php endif ?>
65 73 </label>
66 74 <?php endif ?>
67 75 <input
@@ -66,10 +74,18 @@
66 74 <?php endif ?>
67 75 <input
68 76 type="text"
69 77 class="datepicker"
70 - name="<?php echo esc_attr( $field['key'] ); ?>"
71 - value="<?php echo esc_attr( $value ); ?>"
72 - id="charitable_field_<?php echo esc_attr( $field['key'] ); ?>_element"
73 - <?php echo charitable_get_arbitrary_attributes( $field ); ?>
78 + name="<?php echo esc_attr( $charitable_field['key'] ); ?>"
79 + value="<?php echo esc_attr( $charitable_value ); ?>"
80 + id="charitable_field_<?php echo esc_attr( $charitable_field['key'] ); ?>_element"
81 + <?php echo charitable_get_arbitrary_attributes( $charitable_field ); // phpcs:ignore ?>
74 82 />
75 -</div>
83 + <?php
84 +
85 + // If there is a description, add it after the input.
86 + if ( isset( $charitable_field['description'] ) && ! empty( $charitable_field['description'] ) ) {
87 + echo '<p class="charitable-field-description">' . wp_kses_post( $charitable_field['description'] ) . '</p>';
88 + }
89 +
90 + ?>
91 +</div>