PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.2.3
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.2.3
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / fields / class-field-date.php

class-field-date.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.2.3, at includes/fields/class-field-date.php

120 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Date Field Class
5 */
6 class WeForms_Form_Field_Date_Free extends WeForms_Field_Contract {
7
8 function __construct() {
9 $this->name = __( 'Date / Time', 'weforms' );
10 $this->input_type = 'date_field';
11 $this->icon = 'calendar-o';
12 }
13
14 /**
15 * Render the text field
16 *
17 * @param array $field_settings
18 * @param integer $form_id
19 *
20 * @return void
21 */
22 public function render( $field_settings, $form_id ) {
23 $value = '';
24 ?>
25 <li <?php $this->print_list_attributes( $field_settings ); ?>>
26 <?php $this->print_label( $field_settings ); ?>
27
28 <div class="wpuf-fields">
29 <input id="wpuf-date-<?php echo $field_settings['name']; ?>" type="text" class="datepicker <?php echo ' wpuf_'.$field_settings['name'].'_'.$form_id; ?>" data-required="<?php echo $field_settings['required'] ?>" data-type="text" name="<?php echo esc_attr( $field_settings['name'] ); ?>" placeholder="<?php echo esc_attr( $field_settings['format'] ); ?>" value="<?php echo esc_attr( $value ) ?>" size="30" />
30 <?php $this->help_text( $field_settings ); ?>
31 </div>
32 <script type="text/javascript">
33 jQuery(function($) {
34 <?php if ( $field_settings['time'] == 'yes' ) { ?>
35 $("#wpuf-date-<?php echo $field_settings['name']; ?>").datetimepicker({ dateFormat: '<?php echo $field_settings["format"]; ?>' });
36 <?php } else { ?>
37 $("#wpuf-date-<?php echo $field_settings['name']; ?>").datepicker({ dateFormat: '<?php echo $field_settings["format"]; ?>' });
38 <?php } ?>
39 });
40 </script>
41
42 </li>
43 <?php
44 }
45
46 /**
47 * Get field options setting
48 *
49 * @return array
50 */
51 public function get_options_settings() {
52 $default_options = $this->get_default_option_settings();
53
54 $settings = array(
55 array(
56 'name' => 'format',
57 'title' => __( 'Date Format', 'weforms' ),
58 'type' => 'text',
59 'section' => 'advanced',
60 'priority' => 23,
61 'help_text' => __( 'The date format', 'weforms' ),
62 ),
63
64 array(
65 'name' => 'time',
66 'title' => '',
67 'type' => 'checkbox',
68 'is_single_opt' => true,
69 'options' => array(
70 'yes' => __( 'Enable time input', 'weforms' )
71 ),
72 'section' => 'advanced',
73 'priority' => 24,
74 'help_text' => '',
75 ),
76
77 array(
78 'name' => 'is_publish_time',
79 'title' => '',
80 'type' => 'checkbox',
81 'is_single_opt' => true,
82 'options' => array(
83 'yes' => __( 'Set this as publish time input', 'weforms' )
84 ),
85 'section' => 'advanced',
86 'priority' => 24,
87 'help_text' => '',
88 ),
89 );
90
91 return array_merge( $default_options, $settings );
92 }
93
94 /**
95 * Get the field props
96 *
97 * @return array
98 */
99 public function get_field_props() {
100 $defaults = $this->default_attributes();
101 $props = array(
102 'format' => 'dd/mm/yy',
103 'time' => '',
104 'is_publish_time' => '',
105 );
106
107 return array_merge( $defaults, $props );
108 }
109
110 /**
111 * Prepare entry
112 *
113 * @param $field
114 *
115 * @return mixed
116 */
117 public function prepare_entry( $field ) {
118 return sanitize_text_field( trim( $_POST[$field['name']] ) );
119 }
120 }