Form builder to get in touch with visitors, grow your email list and collect payments — Happyforms - Version 1.6.3

Version Description

  • Improvement: minor rewordings in form Customize screen.
  • Bugfix: Date part validation and value storage were misbehaving.
Download this release

Release Info

Developer thethemefoundry
Plugin Icon 128x128 Form builder to get in touch with visitors, grow your email list and collect payments — Happyforms
Version 1.6.3
Comparing to
See all releases

Code changes from version 1.6.2 to 1.6.3

happyforms.php CHANGED
@@ -5,7 +5,7 @@
5
  * Plugin URI: https://happyforms.me
6
  * Description: Your friendly drag and drop contact form builder for creating contact forms, lead generation forms, feedback forms, quote forms, survey forms and more!
7
  * Author: The Theme Foundry
8
- * Version: 1.6.2
9
  * Author URI: https://thethemefoundry.com
10
  * Upgrade URI: https://thethemefoundry.com
11
  */
@@ -13,7 +13,7 @@
13
  /**
14
  * The current version of the plugin.
15
  */
16
- define( 'HAPPYFORMS_VERSION', '1.6.2' );
17
 
18
  if ( ! function_exists( 'happyforms_plugin_file' ) ):
19
  /**
5
  * Plugin URI: https://happyforms.me
6
  * Description: Your friendly drag and drop contact form builder for creating contact forms, lead generation forms, feedback forms, quote forms, survey forms and more!
7
  * Author: The Theme Foundry
8
+ * Version: 1.6.3
9
  * Author URI: https://thethemefoundry.com
10
  * Upgrade URI: https://thethemefoundry.com
11
  */
13
  /**
14
  * The current version of the plugin.
15
  */
16
+ define( 'HAPPYFORMS_VERSION', '1.6.3' );
17
 
18
  if ( ! function_exists( 'happyforms_plugin_file' ) ):
19
  /**
inc/classes/parts/class-part-date.php CHANGED
@@ -169,34 +169,42 @@ class HappyForms_Part_Date extends HappyForms_Form_Part {
169
  */
170
  public function validate_value( $value, $part = array(), $form = array() ) {
171
  $validated_value = $value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
 
173
  // Missing value components
174
- if ( 1 === $part['required'] ) {
175
- $components = array_keys( $validated_value );
176
-
177
- switch( $part['date_type'] ) {
178
- case 'date':
179
- $components = array( 'year', 'month', 'day' );
180
- break;
181
- case 'datetime':
182
- $components = ( '12' == $part['time_format'] ) ?
183
- array( 'year', 'month', 'day', 'hour', 'minute', 'period' ) :
184
- array( 'year', 'month', 'day', 'hour', 'minute' );
185
- break;
186
- case 'time':
187
- $components = ( '12' == $part['time_format'] ) ?
188
- array( 'hour', 'minute', 'period' ) :
189
- array( 'hour', 'minute' );
190
- break;
191
- }
192
 
193
- $validated_components = array_intersect_key( $validated_value, array_flip( $components ) );
 
 
 
194
 
195
- foreach( $validated_components as $component ) {
196
- if ( '' === $component ) {
197
- return new WP_Error( 'error', __( 'This field is required.', 'happyforms' ) );
198
- }
199
- }
200
  }
201
 
202
  // Year, month, day
@@ -210,7 +218,7 @@ class HappyForms_Part_Date extends HappyForms_Form_Part {
210
  if ( $year > $max_year || $year < $min_year ) {
211
  return new WP_Error(
212
  'error',
213
- __( 'Year input does not match maximum value allowed.', 'happyforms' )
214
  );
215
  }
216
  }
@@ -270,23 +278,18 @@ class HappyForms_Part_Date extends HappyForms_Form_Part {
270
 
271
  public function stringify_value( $value, $part, $form ) {
272
  if ( $this->type === $part['type'] ) {
273
- // Return early if date is incomplete.
274
- foreach( $value as $component ) {
275
- if ( '' === $component ) {
276
- return '';
277
- }
278
- }
279
 
280
- extract( $value );
281
-
282
- if ( '' !== implode( '', array_values( $value ) ) ) {
283
  $months = happyforms_get_months();
284
- $month = $months[intval( $month )];
285
- $day = intval( $day );
286
-
287
- if ( ! isset( $period ) ) {
288
- $period = '';
289
- }
290
 
291
  switch ( $part['date_type'] ) {
292
  case 'date':
@@ -294,8 +297,17 @@ class HappyForms_Part_Date extends HappyForms_Form_Part {
294
  break;
295
  case 'time':
296
  $value = "{$hour}:{$minute}";
 
 
 
 
 
297
  case 'datetime':
298
- $value = "{$month} {$day}, {$year} at {$hour}:{$minute} {$period}";
 
 
 
 
299
  break;
300
  default:
301
  $value = '';
169
  */
170
  public function validate_value( $value, $part = array(), $form = array() ) {
171
  $validated_value = $value;
172
+ $components = array_keys( $validated_value );
173
+
174
+ switch( $part['date_type'] ) {
175
+ case 'date':
176
+ $components = array( 'year', 'month', 'day' );
177
+ break;
178
+ case 'datetime':
179
+ $components = ( '12' == $part['time_format'] ) ?
180
+ array( 'year', 'month', 'day', 'hour', 'minute', 'period' ) :
181
+ array( 'year', 'month', 'day', 'hour', 'minute' );
182
+ break;
183
+ case 'time':
184
+ $components = ( '12' == $part['time_format'] ) ?
185
+ array( 'hour', 'minute', 'period' ) :
186
+ array( 'hour', 'minute' );
187
+ break;
188
+ }
189
+
190
+ $validated_components = array_intersect_key( $validated_value, array_flip( $components ) );
191
+ $filled_components = array_filter( $validated_components );
192
+ $value_is_empty = ( 0 === count( $filled_components ) );
193
+ $value_is_complete = count( $filled_components ) === count( $validated_components );
194
 
195
  // Missing value components
196
+ if ( 1 === $part['required'] && ! $value_is_complete ) {
197
+ return new WP_Error( 'error', __( 'This field is required.', 'happyforms' ) );
198
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
+ // Set to empty if partially incomplete
201
+ if ( ! $value_is_empty && ! $value_is_complete ) {
202
+ return $this->get_default_value( $part );
203
+ }
204
 
205
+ // Return if completely empty
206
+ if ( $value_is_empty ) {
207
+ return $this->get_default_value( $part );
 
 
208
  }
209
 
210
  // Year, month, day
218
  if ( $year > $max_year || $year < $min_year ) {
219
  return new WP_Error(
220
  'error',
221
+ __( 'Year input does not match minimum and maximum value allowed.', 'happyforms' )
222
  );
223
  }
224
  }
278
 
279
  public function stringify_value( $value, $part, $form ) {
280
  if ( $this->type === $part['type'] ) {
281
+ $filled_components = array_filter( $value );
282
+ $value_is_empty = ( 0 === count( $filled_components ) );
 
 
 
 
283
 
284
+ if ( ! $value_is_empty ) {
285
+ $year = intval( $value['year'] );
 
286
  $months = happyforms_get_months();
287
+ $month = intval( $value['month'] );
288
+ $month = isset( $months[$month] ) ? $months[$month] : '';
289
+ $day = intval( $value['day'] );
290
+ $hour = sprintf( '%02d', intval( $value['hour'] ) );
291
+ $minute = sprintf( '%02d', intval( $value['minute'] ) );
292
+ $period = $value['period'];
293
 
294
  switch ( $part['date_type'] ) {
295
  case 'date':
297
  break;
298
  case 'time':
299
  $value = "{$hour}:{$minute}";
300
+
301
+ if ( '12' == $part['time_format'] ) {
302
+ $value .= " {$period}";
303
+ }
304
+ break;
305
  case 'datetime':
306
+ $value = "{$month} {$day}, {$year} at {$hour}:{$minute}";
307
+
308
+ if ( '12' == $part['time_format'] ) {
309
+ $value .= " {$period}";
310
+ }
311
  break;
312
  default:
313
  $value = '';
inc/templates/customize-form-setup.php CHANGED
@@ -30,7 +30,7 @@
30
  </div>
31
  <div id="happyforms-confirmation-email-settings"<% if ( send_confirmation_email ) { %> style="display: block"<% } %>>
32
  <div class="customize-control" >
33
- <label for="confirmation_email_from_name" class="customize-control-title"><?php _e( 'Email from', 'happyforms' ); ?> <i class="fa fa-question-circle" aria-hidden="true" data-pointer="confirmation_email_from_name"></i></label>
34
  <input type="text" id="confirmation_email_from_name" value="<%= confirmation_email_from_name %>" data-attribute="confirmation_email_from_name" data-pointer-target />
35
  </div>
36
  <div class="customize-control" >
@@ -49,7 +49,7 @@
49
  <input type="text" id="form_redirect_url" value="<%= redirect_url %>" data-attribute="redirect_url" data-pointer-target />
50
  </div>
51
  <div class="customize-control">
52
- <label for="form_submit_button_label" class="customize-control-title"><?php _e( 'Submit button text', 'happyforms' ); ?></label>
53
  <input type="text" id="form_submit_button_label" value="<%= submit_button_label %>" data-attribute="submit_button_label" data-pointer-target />
54
  </div>
55
  <div class="customize-control customize-control-checkbox">
30
  </div>
31
  <div id="happyforms-confirmation-email-settings"<% if ( send_confirmation_email ) { %> style="display: block"<% } %>>
32
  <div class="customize-control" >
33
+ <label for="confirmation_email_from_name" class="customize-control-title"><?php _e( 'Email display name', 'happyforms' ); ?> <i class="fa fa-question-circle" aria-hidden="true" data-pointer="confirmation_email_from_name"></i></label>
34
  <input type="text" id="confirmation_email_from_name" value="<%= confirmation_email_from_name %>" data-attribute="confirmation_email_from_name" data-pointer-target />
35
  </div>
36
  <div class="customize-control" >
49
  <input type="text" id="form_redirect_url" value="<%= redirect_url %>" data-attribute="redirect_url" data-pointer-target />
50
  </div>
51
  <div class="customize-control">
52
+ <label for="form_submit_button_label" class="customize-control-title"><?php _e( 'Submit button label', 'happyforms' ); ?></label>
53
  <input type="text" id="form_submit_button_label" value="<%= submit_button_label %>" data-attribute="submit_button_label" data-pointer-target />
54
  </div>
55
  <div class="customize-control customize-control-checkbox">
inc/templates/customize-form-steps.php CHANGED
@@ -1,11 +1,11 @@
1
  <script type="text/template" id="happyforms-form-steps-template">
2
  <div class="happyforms-action-buttons">
3
  <% if ( step.index > 1 ) { %>
4
- <%
5
- var previousStepTitle = '<?php _e( 'Build', 'happyforms' ); ?>';
6
 
7
  if ( 3 === step.index ) {
8
- previousStepTitle = '<?php _e( 'Setup', 'happyforms' ); ?>';
9
  }
10
  %>
11
  <button class="button button-secondary button-hero happyforms-step-previous"><i class="fa fa-lg fa-arrow-circle-o-left" aria-hidden="true"></i> <%= previousStepTitle %></button>
@@ -20,7 +20,7 @@
20
  %>
21
  <button class="button button-primary button-hero button-forwards happyforms-step-next"><%= nextStepTitle %> <i class="fa fa-lg fa-arrow-circle-o-right" aria-hidden="true"></i></button>
22
  <% } else { %>
23
- <button class="button button-primary button-hero button-forwards happyforms-step-save"><?php _e( 'Finish', 'happyforms' ); ?></button>
24
  <% } %>
25
  </div>
26
 
1
  <script type="text/template" id="happyforms-form-steps-template">
2
  <div class="happyforms-action-buttons">
3
  <% if ( step.index > 1 ) { %>
4
+ <%
5
+ var previousStepTitle = '<?php _e( 'Build', 'happyforms' ); ?>';
6
 
7
  if ( 3 === step.index ) {
8
+ previousStepTitle = '<?php _e( 'Setup', 'happyforms' ); ?>';
9
  }
10
  %>
11
  <button class="button button-secondary button-hero happyforms-step-previous"><i class="fa fa-lg fa-arrow-circle-o-left" aria-hidden="true"></i> <%= previousStepTitle %></button>
20
  %>
21
  <button class="button button-primary button-hero button-forwards happyforms-step-next"><%= nextStepTitle %> <i class="fa fa-lg fa-arrow-circle-o-right" aria-hidden="true"></i></button>
22
  <% } else { %>
23
+ <button class="button button-primary button-hero button-forwards happyforms-step-save"><?php _e( 'Save form', 'happyforms' ); ?></button>
24
  <% } %>
25
  </div>
26
 
inc/templates/parts/frontend-date.php CHANGED
@@ -7,7 +7,7 @@
7
 
8
  <div class="happyforms-part__el">
9
  <?php do_action( 'happyforms_part_input_before', $part, $form ); ?>
10
-
11
  <?php if ( $part['date_type'] === 'datetime' || $part['date_type'] === 'date' ) : ?>
12
  <?php
13
  if ( 'month_first' === happyforms_get_site_date_format() ) {
@@ -83,13 +83,12 @@
83
  if ( 12 === $part['time_format'] ) {
84
  $hour_pattern = '(0[0-9]|1[0-2])';
85
  $hour_date_string = 'h';
86
- $default_hour = '12';
87
  } else {
88
  $hour_pattern = '(0[0-9]|1[0-9]|2[0-3])';
89
  $hour_date_string = 'H';
90
- $default_hour = '00';
91
  }
92
 
 
93
  $happyforms_hour_value = ( happyforms_get_part_value( $part, $form, 'hour' ) ) ? happyforms_get_part_value( $part, $form, 'hour' ) : $default_hour;
94
  $hour_value = ( 'current' === $part['default_datetime'] ) ? date( $hour_date_string, $current_timestamp ) : $happyforms_hour_value;
95
  ?>
7
 
8
  <div class="happyforms-part__el">
9
  <?php do_action( 'happyforms_part_input_before', $part, $form ); ?>
10
+
11
  <?php if ( $part['date_type'] === 'datetime' || $part['date_type'] === 'date' ) : ?>
12
  <?php
13
  if ( 'month_first' === happyforms_get_site_date_format() ) {
83
  if ( 12 === $part['time_format'] ) {
84
  $hour_pattern = '(0[0-9]|1[0-2])';
85
  $hour_date_string = 'h';
 
86
  } else {
87
  $hour_pattern = '(0[0-9]|1[0-9]|2[0-3])';
88
  $hour_date_string = 'H';
 
89
  }
90
 
91
+ $default_hour = sprintf( '%02d', intval( $part['min_hour'] ) );
92
  $happyforms_hour_value = ( happyforms_get_part_value( $part, $form, 'hour' ) ) ? happyforms_get_part_value( $part, $form, 'hour' ) : $default_hour;
93
  $hour_value = ( 'current' === $part['default_datetime'] ) ? date( $hour_date_string, $current_timestamp ) : $happyforms_hour_value;
94
  ?>
languages/happyforms.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the HappyForms package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: HappyForms 1.6.2\n"
6
  "Report-Msgid-Bugs-To: https://thethemefoundry.com/support/\n"
7
- "POT-Creation-Date: 2018-09-12 15:17:01+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -990,15 +990,15 @@ msgstr ""
990
  msgid "Date"
991
  msgstr ""
992
 
993
- #: inc/classes/parts/class-part-date.php:213
994
- msgid "Year input does not match maximum value allowed."
995
  msgstr ""
996
 
997
- #: inc/classes/parts/class-part-date.php:228
998
  msgid "Hour input does not match minimum and maximum value allowed."
999
  msgstr ""
1000
 
1001
- #: inc/classes/parts/class-part-date.php:265
1002
  msgid "Not a valid date."
1003
  msgstr ""
1004
 
@@ -2418,7 +2418,7 @@ msgid "Send confirmation email"
2418
  msgstr ""
2419
 
2420
  #: inc/templates/customize-form-setup.php:33
2421
- msgid "Email from"
2422
  msgstr ""
2423
 
2424
  #: inc/templates/customize-form-setup.php:41
@@ -2430,7 +2430,7 @@ msgid "On complete redirect link"
2430
  msgstr ""
2431
 
2432
  #: inc/templates/customize-form-setup.php:52
2433
- msgid "Submit button text"
2434
  msgstr ""
2435
 
2436
  #: inc/templates/customize-form-setup.php:58
@@ -2529,7 +2529,7 @@ msgid "Build"
2529
  msgstr ""
2530
 
2531
  #: inc/templates/customize-form-steps.php:23
2532
- msgid "Finish"
2533
  msgstr ""
2534
 
2535
  #: inc/templates/customize-form-steps.php:30
@@ -3182,15 +3182,15 @@ msgstr ""
3182
  msgid "Year"
3183
  msgstr ""
3184
 
3185
- #: inc/templates/parts/frontend-date.php:130
3186
  msgid "Period"
3187
  msgstr ""
3188
 
3189
- #: inc/templates/parts/frontend-date.php:142
3190
  msgid "AM"
3191
  msgstr ""
3192
 
3193
- #: inc/templates/parts/frontend-date.php:143
3194
  msgid "PM"
3195
  msgstr ""
3196
 
2
  # This file is distributed under the same license as the HappyForms package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: HappyForms 1.6.3\n"
6
  "Report-Msgid-Bugs-To: https://thethemefoundry.com/support/\n"
7
+ "POT-Creation-Date: 2018-09-13 14:03:03+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
990
  msgid "Date"
991
  msgstr ""
992
 
993
+ #: inc/classes/parts/class-part-date.php:221
994
+ msgid "Year input does not match minimum and maximum value allowed."
995
  msgstr ""
996
 
997
+ #: inc/classes/parts/class-part-date.php:236
998
  msgid "Hour input does not match minimum and maximum value allowed."
999
  msgstr ""
1000
 
1001
+ #: inc/classes/parts/class-part-date.php:273
1002
  msgid "Not a valid date."
1003
  msgstr ""
1004
 
2418
  msgstr ""
2419
 
2420
  #: inc/templates/customize-form-setup.php:33
2421
+ msgid "Email display name"
2422
  msgstr ""
2423
 
2424
  #: inc/templates/customize-form-setup.php:41
2430
  msgstr ""
2431
 
2432
  #: inc/templates/customize-form-setup.php:52
2433
+ msgid "Submit button label"
2434
  msgstr ""
2435
 
2436
  #: inc/templates/customize-form-setup.php:58
2529
  msgstr ""
2530
 
2531
  #: inc/templates/customize-form-steps.php:23
2532
+ msgid "Save form"
2533
  msgstr ""
2534
 
2535
  #: inc/templates/customize-form-steps.php:30
3182
  msgid "Year"
3183
  msgstr ""
3184
 
3185
+ #: inc/templates/parts/frontend-date.php:129
3186
  msgid "Period"
3187
  msgstr ""
3188
 
3189
+ #: inc/templates/parts/frontend-date.php:141
3190
  msgid "AM"
3191
  msgstr ""
3192
 
3193
+ #: inc/templates/parts/frontend-date.php:142
3194
  msgid "PM"
3195
  msgstr ""
3196
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: contact, contact form, email, feedback form, form, form builder, custom fo
5
  Requires at least: 4.8
6
  Tested up to: 4.9.7
7
  Requires PHP: 5.2.4
8
- Stable tag: 1.6.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -79,6 +79,10 @@ Absolutely! HappyForms gets out of the way and is designed to work with any them
79
 
80
  == Changelog ==
81
 
 
 
 
 
82
  = 1.6.2 =
83
  * Bugfix: Date part validation was preventing valid submissions.
84
  * Bugfix: Number part was erroneously preventing valid empty submissions.
@@ -258,6 +262,9 @@ Absolutely! HappyForms gets out of the way and is designed to work with any them
258
 
259
  == Upgrade Notice ==
260
 
 
 
 
261
  = 1.6.2 =
262
  * Bugfixes.
263
 
5
  Requires at least: 4.8
6
  Tested up to: 4.9.7
7
  Requires PHP: 5.2.4
8
+ Stable tag: 1.6.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
79
 
80
  == Changelog ==
81
 
82
+ = 1.6.3 =
83
+ * Improvement: minor rewordings in form Customize screen.
84
+ * Bugfix: Date part validation and value storage were misbehaving.
85
+
86
  = 1.6.2 =
87
  * Bugfix: Date part validation was preventing valid submissions.
88
  * Bugfix: Number part was erroneously preventing valid empty submissions.
262
 
263
  == Upgrade Notice ==
264
 
265
+ = 1.6.3 =
266
+ * Bugfixes.
267
+
268
  = 1.6.2 =
269
  * Bugfixes.
270