PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.3.3
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.3.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
← All changes | includes/fields/class-field-date.php +120 -132 1.6.31.3.3 View file →
@@ -1,132 +1,120 @@
1 -<?php
2 -
3 -/**
4 - * Date Field Class
5 - */
6 -class WeForms_Form_Field_Date_Free extends WeForms_Field_Contract {
7 -
8 - public 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 int $form_id
19 - *
20 - * @return void
21 - */
22 - public function render( $field_settings, $form_id ) {
23 - $value = ''; ?>
24 - <li <?php $this->print_list_attributes( $field_settings ); ?>>
25 - <?php $this->print_label( $field_settings ); ?>
26 -
27 - <div class="wpuf-fields">
28 - <input id="wpuf-date-<?php echo esc_attr( $field_settings['name'] ); ?>" type="text" class="datepicker <?php echo ' wpuf_'.esc_attr( $field_settings['name'] ).'_'. esc_attr($form_id); ?>" data-required="<?php echo esc_attr($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" />
29 - <?php $this->help_text( $field_settings ); ?>
30 - </div>
31 - </li>
32 - <?php
33 -
34 - $name = $field_settings['name'];
35 - $format = $field_settings["format"];
36 -
37 - if ( $field_settings['time'] == 'yes' ) {
38 - $script = "jQuery(function($) {
39 - $('#wpuf-date-{$name}').datetimepicker({ dateFormat: '{$format}' });
40 - });";
41 - } else {
42 - $script = "jQuery(function($) {
43 - $('#wpuf-date-{$name}').datepicker({ dateFormat: '{$format}' });
44 - });";
45 - }
46 -
47 - wp_add_inline_script( 'wpuf-form', $script );
48 - }
49 -
50 - /**
51 - * Get field options setting
52 - *
53 - * @return array
54 - */
55 - public function get_options_settings() {
56 - $default_options = $this->get_default_option_settings();
57 -
58 - $settings = [
59 - [
60 - 'name' => 'format',
61 - 'title' => __( 'Date Format', 'weforms' ),
62 - 'type' => 'text',
63 - 'section' => 'advanced',
64 - 'priority' => 23,
65 - 'help_text' => __( 'The date format', 'weforms' ),
66 - ],
67 - [
68 - 'name' => 'time',
69 - 'title' => '',
70 - 'type' => 'checkbox',
71 - 'is_single_opt' => true,
72 - 'options' => [
73 - 'yes' => __( 'Enable time input', 'weforms' ),
74 - ],
75 - 'section' => 'advanced',
76 - 'priority' => 24,
77 - 'help_text' => '',
78 - ],
79 - [
80 - 'name' => 'is_publish_time',
81 - 'title' => '',
82 - 'type' => 'checkbox',
83 - 'is_single_opt' => true,
84 - 'options' => [
85 - 'yes' => __( 'Set this as publish time input', 'weforms' ),
86 - ],
87 - 'section' => 'advanced',
88 - 'priority' => 24,
89 - 'help_text' => '',
90 - ],
91 - ];
92 -
93 - return array_merge( $default_options, $settings );
94 - }
95 -
96 - /**
97 - * Get the field props
98 - *
99 - * @return array
100 - */
101 - public function get_field_props() {
102 - $defaults = $this->default_attributes();
103 - $props = [
104 - 'format' => 'dd/mm/yy',
105 - 'time' => '',
106 - 'is_publish_time' => '',
107 - ];
108 -
109 - return array_merge( $defaults, $props );
110 - }
111 -
112 - /**
113 - * Prepare entry
114 - *
115 - * @param $field
116 - *
117 - * @return mixed
118 - */
119 - public function prepare_entry( $field, $args = [] ) {
120 - if( empty( $_POST['_wpnonce'] ) ) {
121 - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
122 - }
123 -
124 - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'wpuf_form_add' ) ) {
125 - wp_send_json_error( __( 'Unauthorized operation', 'weforms' ) );
126 - }
127 -
128 - $args = ! empty( $args ) ? $args : weforms_clean( $_POST );
129 -
130 - return sanitize_text_field( trim( $args[$field['name']] ) );
131 - }
132 -}
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 +}