| @@ -11,9 +11,9 @@ | ||
| 11 | 11 | $this->icon = 'calendar-o'; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Render the text field | |
| 15 | + * Render the date field | |
| 16 | 16 | * |
| 17 | 17 | * @param array $field_settings |
| 18 | 18 | * @param int $form_id |
| 19 | 19 | * |
| @@ -19,14 +19,31 @@ | ||
| 19 | 19 | * |
| 20 | 20 | * @return void |
| 21 | 21 | */ |
| 22 | 22 | public function render( $field_settings, $form_id ) { |
| 23 | - $value = ''; ?> | |
| 23 | + $use_theme_css = isset( $form_settings['use_theme_css'] ) ? $form_settings['use_theme_css'] : 'wpuf-style'; | |
| 24 | + $value = ''; | |
| 25 | + ?> | |
| 24 | 26 | <li <?php $this->print_list_attributes( $field_settings ); ?>> |
| 25 | 27 | <?php $this->print_label( $field_settings ); ?> |
| 26 | 28 | |
| 27 | 29 | <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" /> | |
| 30 | + <input | |
| 31 | + id="wpuf-date-<?php echo esc_attr( $field_settings['name'] ); ?>" | |
| 32 | + type="text" | |
| 33 | + <?php | |
| 34 | + $field_settings['enforce_format'] = ! isset( $field_settings['enforce_format'] ) ? '' : $field_settings['enforce_format']; | |
| 35 | + echo esc_attr( $field_settings['enforce_format'] !== 'yes' ) ? '' : 'readonly'; | |
| 36 | + ?> | |
| 37 | + class="datepicker <?php echo ' wpuf_'.esc_attr( $field_settings['name'] ).'_'. esc_attr($form_id); ?>" | |
| 38 | + data-required="<?php echo esc_attr($field_settings['required']) ?>" | |
| 39 | + data-type="text" | |
| 40 | + data-style="<?php echo esc_attr( $use_theme_css ); ?>" | |
| 41 | + name="<?php echo esc_attr( $field_settings['name'] ); ?>" | |
| 42 | + placeholder="<?php echo esc_attr( $field_settings['format'] ); ?>" | |
| 43 | + value="<?php echo esc_attr( $value ) ?>" | |
| 44 | + size="30" | |
| 45 | + /> | |
| 29 | 46 | <?php $this->help_text( $field_settings ); ?> |
| 30 | 47 | </div> |
| 31 | 48 | </li> |
| 32 | 49 | <?php |
| @@ -57,13 +74,13 @@ | ||
| 57 | 74 | |
| 58 | 75 | $settings = [ |
| 59 | 76 | [ |
| 60 | 77 | 'name' => 'format', |
| 61 | - 'title' => __( 'Date Format', 'weforms' ), | |
| 78 | + 'title' => esc_html__( 'Date Format', 'weforms' ), | |
| 62 | 79 | 'type' => 'text', |
| 63 | 80 | 'section' => 'advanced', |
| 64 | 81 | 'priority' => 23, |
| 65 | - 'help_text' => __( 'The date format', 'weforms' ), | |
| 82 | + 'help_text' => esc_html__( 'The date format', 'weforms' ), | |
| 66 | 83 | ], |
| 67 | 84 | [ |
| 68 | 85 | 'name' => 'time', |
| 69 | 86 | 'title' => '', |
| @@ -69,9 +86,9 @@ | ||
| 69 | 86 | 'title' => '', |
| 70 | 87 | 'type' => 'checkbox', |
| 71 | 88 | 'is_single_opt' => true, |
| 72 | 89 | 'options' => [ |
| 73 | - 'yes' => __( 'Enable time input', 'weforms' ), | |
| 90 | + 'yes' => esc_html__( 'Enable time input', 'weforms' ), | |
| 74 | 91 | ], |
| 75 | 92 | 'section' => 'advanced', |
| 76 | 93 | 'priority' => 24, |
| 77 | 94 | 'help_text' => '', |
| @@ -81,14 +98,27 @@ | ||
| 81 | 98 | 'title' => '', |
| 82 | 99 | 'type' => 'checkbox', |
| 83 | 100 | 'is_single_opt' => true, |
| 84 | 101 | 'options' => [ |
| 85 | - 'yes' => __( 'Set this as publish time input', 'weforms' ), | |
| 102 | + 'yes' => esc_html__( 'Set this as publish time input', 'weforms' ), | |
| 86 | 103 | ], |
| 87 | 104 | 'section' => 'advanced', |
| 88 | 105 | 'priority' => 24, |
| 89 | 106 | 'help_text' => '', |
| 90 | 107 | ], |
| 108 | + [ | |
| 109 | + 'name' => 'enforce_format', | |
| 110 | + 'title' => __( 'Toggle Keyboard input for Date', 'weforms' ), | |
| 111 | + 'type' => 'checkbox', | |
| 112 | + 'section' => 'advanced', | |
| 113 | + 'is_single_opt' => true, | |
| 114 | + 'options' => [ | |
| 115 | + 'yes' => esc_html__( 'Force Datepicker Input', 'weforms' ), | |
| 116 | + ], | |
| 117 | + 'default' => 'yes', | |
| 118 | + 'priority' => 24, | |
| 119 | + 'help_text' => esc_html__( 'Disables Keyboard Input and uses the Datepicker Format', 'weforms' ), | |
| 120 | + ], | |
| 91 | 121 | ]; |
| 92 | 122 | |
| 93 | 123 | return array_merge( $default_options, $settings ); |
| 94 | 124 | } |
| @@ -103,8 +133,9 @@ | ||
| 103 | 133 | $props = [ |
| 104 | 134 | 'format' => 'dd/mm/yy', |
| 105 | 135 | 'time' => '', |
| 106 | 136 | 'is_publish_time' => '', |
| 137 | + 'enforce_format' => '', | |
| 107 | 138 | ]; |
| 108 | 139 | |
| 109 | 140 | return array_merge( $defaults, $props ); |
| 110 | 141 | } |