PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.6.31
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.6.31
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 1.8.0 All 210 releases
charitable / templates / form-fields / datepicker.php

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

72 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The template used to display datepicker form fields.
4 *
5 * @author Studio 164a
6 * @package Charitable/Templates/Form Fields
7 * @since 1.0.0
8 * @version 1.6.23
9 */
10
11 if ( ! isset( $view_args['form'] ) || ! isset( $view_args['field'] ) ) {
12 return;
13 }
14
15 $form = $view_args['form'];
16 $field = $view_args['field'];
17 $classes = esc_attr( $view_args['classes'] );
18 $is_required = isset( $field['required'] ) ? $field['required'] : false;
19 $value = isset( $field['value'] ) ? esc_attr( $field['value'] ) : '';
20 $min_date = isset( $field['min_date'] ) ? esc_attr( $field['min_date'] ) : '';
21 $max_date = isset( $field['max_date'] ) ? esc_attr( $field['max_date'] ) : '';
22 $year_range = array_key_exists( 'year_range', $field ) ? $field['year_range'] : 'c-100:c';
23 $date_format = array_key_exists( 'date_format', $field ) ? $field['date_format'] : 'MM d, yy';
24 $json_args = array(
25 'changeMonth' => true,
26 'changeYear' => true,
27 'dateFormat' => $date_format,
28 'yearRange' => $year_range,
29 );
30
31 if ( array_key_exists( 'min_date', $field ) ) {
32 $json_args['minDate'] = '+' . $field['min_date'];
33 }
34
35 if ( array_key_exists( 'max_date', $field ) ) {
36 $json_args['maxDate'] = '+' . $field['max_date'];
37 }
38
39 /* Enqueue the datepicker */
40 if ( ! wp_script_is( 'jquery-ui-datepicker' ) ) {
41 wp_enqueue_script( 'jquery-ui-datepicker' );
42 }
43
44 $datepicker_json_args = json_encode( $json_args );
45
46 wp_add_inline_script(
47 'jquery-ui-datepicker',
48 "jQuery(document).ready( function(){ jQuery( '.datepicker' ).datepicker( {$datepicker_json_args} ); });"
49 );
50
51 wp_enqueue_style( 'charitable-datepicker' );
52
53 ?>
54 <div id="charitable_field_<?php echo esc_attr( $field['key'] ); ?>" class="<?php echo $classes; ?>">
55 <?php if ( isset( $field['label'] ) ) : ?>
56 <label for="charitable_field_<?php echo esc_attr( $field['key'] ); ?>_element">
57 <?php echo $field['label']; ?>
58 <?php if ( $is_required ) : ?>
59 <abbr class="required" title="required">*</abbr>
60 <?php endif ?>
61 </label>
62 <?php endif ?>
63 <input
64 type="text"
65 class="datepicker"
66 name="<?php echo esc_attr( $field['key'] ); ?>"
67 value="<?php echo esc_attr( $value ); ?>"
68 id="charitable_field_<?php echo esc_attr( $field['key'] ); ?>_element"
69 <?php echo charitable_get_arbitrary_attributes( $field ); ?>
70 />
71 </div>
72