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.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 1.7.0.9 All 211 releases
charitable / templates / form-fields / datepicker.php

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

91 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 datepicker form fields.
10 *
11 * @author WP Charitable LLC
12 * @package Charitable/Templates/Form Fields
13 * @since 1.0.0
14 * @version 1.6.40
15 * @version 1.8.6.1 Added description output.
16 * @version 1.8.8.6
17 */
18
19 if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) {
20 return;
21 }
22
23 global $wp_locale;
24
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(
35 'changeMonth' => true,
36 'changeYear' => true,
37 'dateFormat' => $charitable_date_format,
38 'yearRange' => $charitable_year_range,
39 'monthNames' => array_values( $wp_locale->month ),
40 'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
41 );
42
43 if ( array_key_exists( 'min_date', $charitable_field ) ) {
44 $charitable_json_args['minDate'] = '+' . $charitable_field['min_date'];
45 }
46
47 if ( array_key_exists( 'max_date', $charitable_field ) ) {
48 $charitable_json_args['maxDate'] = '+' . $charitable_field['max_date'];
49 }
50
51 /* Enqueue the datepicker */
52 if ( ! wp_script_is( 'jquery-ui-datepicker' ) ) {
53 wp_enqueue_script( 'jquery-ui-datepicker' );
54 }
55
56 $charitable_datepicker_json_args = wp_json_encode( $charitable_json_args );
57
58 wp_add_inline_script(
59 'jquery-ui-datepicker',
60 "jQuery(document).ready( function(){ jQuery( '.datepicker' ).datepicker( {$charitable_datepicker_json_args} ); });"
61 );
62
63 wp_enqueue_style( 'charitable-datepicker' );
64
65 ?>
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>
72 <?php endif ?>
73 </label>
74 <?php endif ?>
75 <input
76 type="text"
77 class="datepicker"
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 ?>
82 />
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>