Ninja Forms – The Easy and Powerful Forms Builder - Version 3.4.3

Version Description

(5 February 2019) =

Bugs:

  • Resolved an issue that was causing some form imports to fail.
  • Submission exports of checkbox fields that have been modified by an admin should now display their proper value in the csv.
  • Resolved an issue that was rarely causing actions to fire twice.

=

Download this release

Release Info

Developer krmoorhouse
Plugin Icon 128x128 Ninja Forms – The Easy and Powerful Forms Builder
Version 3.4.3
Comparing to
See all releases

Code changes from version 3.4.2 to 3.4.3

assets/js/admin-import-export.js CHANGED
@@ -33,8 +33,28 @@ jQuery( document ).ready( function( $ ) {
33
  if ( 'undefined' == typeof response.form_id ) return false;
34
 
35
  jQuery( '#nf-import-file' ).val('');;
36
- jQuery( '#nf-import-url' ).attr( 'href', nfAdmin.builderURL + response.form_id );
37
- jQuery( '#row-nf-import-response' ).show();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
  }
40
 
@@ -63,6 +83,7 @@ jQuery( document ).ready( function( $ ) {
63
  $( document ).on( 'change', '#nf-import-file', function( e ) {
64
  // Hide our success message.
65
  jQuery( '#row-nf-import-response' ).hide();
 
66
  // Hide our extension type error.
67
  jQuery( '#row-nf-import-type-error' ).hide();
68
 
33
  if ( 'undefined' == typeof response.form_id ) return false;
34
 
35
  jQuery( '#nf-import-file' ).val('');;
36
+ jQuery( '#nf-import-url' ).attr( 'href', nfAdmin.builderURL + response.form_id );
37
+ var blockingErrors = false;
38
+ // If we have errors...
39
+ if ( 'undefined' != typeof response.errors ) {
40
+ var errorOutput = '';
41
+ // Record them.
42
+ response.errors.forEach(
43
+ function( error ) {
44
+ // Block success if one was fatal.
45
+ if ( 'fatal' == error.type ) {
46
+ blockingErrors = true;
47
+ }
48
+ console.error( error.type + ': ' + error.code );
49
+ errorOutput += '<p>' + error.message + '</p>';
50
+ }
51
+ );
52
+ jQuery( '#row-nf-import-response-error td' ).html( errorOutput );
53
+ jQuery( '#row-nf-import-response-error' ).show();
54
+ }
55
+ if ( ! blockingErrors ) {
56
+ jQuery( '#row-nf-import-response' ).show();
57
+ }
58
  }
59
  }
60
 
83
  $( document ).on( 'change', '#nf-import-file', function( e ) {
84
  // Hide our success message.
85
  jQuery( '#row-nf-import-response' ).hide();
86
+ jQuery( '#row-nf-import-response-error' ).hide();
87
  // Hide our extension type error.
88
  jQuery( '#row-nf-import-type-error' ).hide();
89
 
deprecated/ninja-forms.php CHANGED
@@ -265,7 +265,7 @@ class Ninja_Forms {
265
 
266
  // Plugin version
267
  if ( ! defined( 'NF_PLUGIN_VERSION' ) )
268
- define( 'NF_PLUGIN_VERSION', '3.4.2' );
269
 
270
  // Plugin Folder Path
271
  if ( ! defined( 'NF_PLUGIN_DIR' ) )
265
 
266
  // Plugin version
267
  if ( ! defined( 'NF_PLUGIN_VERSION' ) )
268
+ define( 'NF_PLUGIN_VERSION', '3.4.3' );
269
 
270
  // Plugin Folder Path
271
  if ( ! defined( 'NF_PLUGIN_DIR' ) )
includes/Abstracts/BatchProcess.php CHANGED
@@ -113,6 +113,29 @@ abstract class NF_Abstracts_BatchProcess
113
  return 1;
114
  }
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  /**
117
  * Function to cleanup any lingering temporary elements of a batch process after completion.
118
  *
@@ -167,10 +190,15 @@ abstract class NF_Abstracts_BatchProcess
167
  * Method that encodes $this->response and sends the data to the front-end.
168
  *
169
  * @since 3.4.0
 
170
  * @return void
171
  */
172
  public function respond()
173
  {
 
 
 
 
174
  echo wp_json_encode( $this->response );
175
  wp_die();
176
  }
113
  return 1;
114
  }
115
 
116
+ /**
117
+ * Adds an error to the response object.
118
+ *
119
+ * @param $slug (String) The slug for this error code.
120
+ * @param $msg (String) The error message to be displayed.
121
+ * @param $type (String) warning or fatal, depending on the error.
122
+ * Defaults to warning.
123
+ *
124
+ * @since UPDATE_VERSION_ON_MERGE
125
+ */
126
+ public function add_error( $slug, $msg, $type = 'warning' )
127
+ {
128
+ // Setup our errors array if it doesn't exist already.
129
+ if ( ! isset( $this->response[ 'errors' ] ) ) {
130
+ $this->response[ 'errors' ] = array();
131
+ }
132
+ $this->response[ 'errors' ][] = array(
133
+ 'code' => $slug,
134
+ 'message' => $msg,
135
+ 'type' => $type
136
+ );
137
+ }
138
+
139
  /**
140
  * Function to cleanup any lingering temporary elements of a batch process after completion.
141
  *
190
  * Method that encodes $this->response and sends the data to the front-end.
191
  *
192
  * @since 3.4.0
193
+ * @updated UPDATE_VERSION_ON_MERGE
194
  * @return void
195
  */
196
  public function respond()
197
  {
198
+ if ( ! empty( $this->response[ 'errors' ] ) ) {
199
+ $this->response[ 'errors' ] = array_unique( $this->response[ 'errors' ] );
200
+ }
201
+
202
  echo wp_json_encode( $this->response );
203
  wp_die();
204
  }
includes/Abstracts/Migration.php CHANGED
@@ -57,7 +57,7 @@ abstract class NF_Abstracts_Migration
57
  $result = $wpdb->query( $sql );
58
  // If we got anything back, say so.
59
  if ( ! empty( $result ) ) $response = true;
60
- return $result;
61
  }
62
 
63
 
57
  $result = $wpdb->query( $sql );
58
  // If we got anything back, say so.
59
  if ( ! empty( $result ) ) $response = true;
60
+ return $response;
61
  }
62
 
63
 
includes/Admin/Processes/ImportForm.php CHANGED
@@ -68,7 +68,7 @@ class NF_Admin_Processes_ImportForm extends NF_Abstracts_BatchProcess
68
  {
69
  // If we aren't passed any form content, bail.
70
  if ( empty ( $_POST[ 'extraData' ][ 'content' ] ) ) {
71
- // TODO: When we add error handling to the batch processor, this should be revisited.
72
  $this->batch_complete();
73
  }
74
 
@@ -84,11 +84,14 @@ class NF_Admin_Processes_ImportForm extends NF_Abstracts_BatchProcess
84
  * We're first going to try to json_decode. If we don't get an array, we'll unserialize.
85
  */
86
 
87
- $decoded_data = json_decode( WPN_Helper::json_cleanup( html_entity_decode( $data ) ), true );
88
-
89
  // If we don't have an array, try unserializing
90
  if ( ! is_array( $decoded_data ) ) {
91
  $decoded_data = WPN_Helper::maybe_unserialize( $data );
 
 
 
92
  }
93
 
94
  // Try to utf8 decode our results.
@@ -99,6 +102,11 @@ class NF_Admin_Processes_ImportForm extends NF_Abstracts_BatchProcess
99
  $data = $decoded_data;
100
  }
101
 
 
 
 
 
 
102
  $data = $this->import_form_backwards_compatibility( $data );
103
 
104
  // $data is now a form array.
@@ -382,7 +390,15 @@ class NF_Admin_Processes_ImportForm extends NF_Abstracts_BatchProcess
382
  */
383
  for ( $i = 0; $i < $this->fields_per_step; $i++ ) {
384
  // If we don't have a field, skip this $i.
385
- if ( ! isset ( $this->form[ 'fields' ][ $i ] ) ) continue;
 
 
 
 
 
 
 
 
386
 
387
  $field_settings = $this->form[ 'fields' ][ $i ];
388
  // Remove a field ID if we have one set.
68
  {
69
  // If we aren't passed any form content, bail.
70
  if ( empty ( $_POST[ 'extraData' ][ 'content' ] ) ) {
71
+ $this->add_error( 'empty_content', __( 'No export provided.', 'ninja-forms' ), 'fatal' );
72
  $this->batch_complete();
73
  }
74
 
84
  * We're first going to try to json_decode. If we don't get an array, we'll unserialize.
85
  */
86
 
87
+ $decoded_data = json_decode( WPN_Helper::json_cleanup( html_entity_decode( $data, ENT_QUOTES ) ), true );
88
+
89
  // If we don't have an array, try unserializing
90
  if ( ! is_array( $decoded_data ) ) {
91
  $decoded_data = WPN_Helper::maybe_unserialize( $data );
92
+ if ( ! is_array( $decoded_data ) ) {
93
+ $decoded_data = json_decode( $decoded_data, true );
94
+ }
95
  }
96
 
97
  // Try to utf8 decode our results.
102
  $data = $decoded_data;
103
  }
104
 
105
+ if ( ! is_array( $data ) ) {
106
+ $this->add_error( 'decode_failed', __( 'Failed to read export. Please try again.', 'ninja-forms' ), 'fatal' );
107
+ $this->batch_complete();
108
+ }
109
+
110
  $data = $this->import_form_backwards_compatibility( $data );
111
 
112
  // $data is now a form array.
390
  */
391
  for ( $i = 0; $i < $this->fields_per_step; $i++ ) {
392
  // If we don't have a field, skip this $i.
393
+ if ( ! isset ( $this->form[ 'fields' ][ $i ] ) ) {
394
+ // Remove this field from our fields array.
395
+ unset( $this->form[ 'fields' ][ $i ] );
396
+ // If we haven't exceeded the field total...
397
+ if ( $i < count( $this->form[ 'fields' ] ) ) {
398
+ $this->add_error( 'empty_field', __( 'Some fields might not have been imported properly.', 'ninja-forms' ) );
399
+ }
400
+ continue;
401
+ }
402
 
403
  $field_settings = $this->form[ 'fields' ][ $i ];
404
  // Remove a field ID if we have one set.
includes/Fields/Checkbox.php CHANGED
@@ -71,7 +71,7 @@ class NF_Fields_Checkbox extends NF_Abstracts_Input
71
  * Custom Columns
72
  * Creates what is displayed in the columns on the submissions page.
73
  * @since 3.0
74
- *
75
  * @param $value checkbox value
76
  * @param $field field model.
77
  * @return $value string|void
@@ -163,7 +163,7 @@ class NF_Fields_Checkbox extends NF_Abstracts_Input
163
  }
164
 
165
  // If the the value and check to see if we have checked and unchecked settings...
166
- if ( 1 == $value && ! empty( $checked_setting ) ) {
167
  // ...if we do return checked setting
168
  return $checked_setting;
169
  } elseif ( 0 == $value && ! empty( $unchecked_setting ) ) {
@@ -172,7 +172,7 @@ class NF_Fields_Checkbox extends NF_Abstracts_Input
172
  /*
173
  * These checks are for checkbox fields that were created before version 3.2.7.
174
  */
175
- } elseif ( 1 == $value ) {
176
  return __( 'checked', 'ninja-forms' );
177
  } elseif ( 0 == $value ) {
178
  return __( 'unchecked', 'ninja-forms' );
71
  * Custom Columns
72
  * Creates what is displayed in the columns on the submissions page.
73
  * @since 3.0
74
+ *nf_subs_export_pre_value
75
  * @param $value checkbox value
76
  * @param $field field model.
77
  * @return $value string|void
163
  }
164
 
165
  // If the the value and check to see if we have checked and unchecked settings...
166
+ if ( ( 1 == $value || 'on' == $value ) && ! empty( $checked_setting ) ) {
167
  // ...if we do return checked setting
168
  return $checked_setting;
169
  } elseif ( 0 == $value && ! empty( $unchecked_setting ) ) {
172
  /*
173
  * These checks are for checkbox fields that were created before version 3.2.7.
174
  */
175
+ } elseif ( 1 == $value || 'on' == $value ) {
176
  return __( 'checked', 'ninja-forms' );
177
  } elseif ( 0 == $value ) {
178
  return __( 'unchecked', 'ninja-forms' );
includes/Templates/admin-metabox-import-export-forms-import.html.php CHANGED
@@ -5,6 +5,10 @@
5
  <th></th>
6
  <td><?php printf( __( 'Form Imported Successfully. %sView Form%s', 'ninja-forms' ), '<a id="nf-import-url" href="#">', '</a>' ); ?></td>
7
  </tr>
 
 
 
 
8
  <tr id="row_nf_import_form">
9
  <th scope="row">
10
  <label for="nf-import-file"><?php echo __( 'Select a file', 'ninja-forms' ); ?></label>
5
  <th></th>
6
  <td><?php printf( __( 'Form Imported Successfully. %sView Form%s', 'ninja-forms' ), '<a id="nf-import-url" href="#">', '</a>' ); ?></td>
7
  </tr>
8
+ <tr id="row-nf-import-response-error" style="display:none;background-color:#ffc;color:red;">
9
+ <th></th>
10
+ <td></td>
11
+ </tr>
12
  <tr id="row_nf_import_form">
13
  <th scope="row">
14
  <label for="nf-import-file"><?php echo __( 'Select a file', 'ninja-forms' ); ?></label>
ninja-forms.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Ninja Forms
4
  Plugin URI: http://ninjaforms.com/
5
  Description: Ninja Forms is a webform builder with unparalleled ease of use and features.
6
- Version: 3.4.2
7
  Author: The WP Ninjas
8
  Author URI: http://ninjaforms.com
9
  Text Domain: ninja-forms
@@ -58,7 +58,7 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
58
  * @since 3.0
59
  */
60
 
61
- const VERSION = '3.4.2';
62
 
63
  /**
64
  * @since 3.4.0
@@ -490,13 +490,15 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
490
  global $wpdb;
491
  $sql = "SELECT COUNT( `id` ) AS total FROM `{$wpdb->prefix}nf3_forms`;";
492
  $result = $wpdb->get_results( $sql, 'ARRAY_A' );
493
- $threshold = 5; // Threshold percentage for our required updates.
494
  // If we got back a list of updates...
495
  // AND If we have any forms on the site...
496
  // AND If the gate is open...
 
497
  if ( ! empty( $required_updates )
498
  && 0 < $result[ 0 ][ 'total' ]
499
- && WPN_Helper::gated_release( $threshold ) ) {
 
500
  // Record that we have updates to run.
501
  update_option( 'ninja_forms_needs_updates', 1 );
502
  } // Otherwise... (Sanity check)
3
  Plugin Name: Ninja Forms
4
  Plugin URI: http://ninjaforms.com/
5
  Description: Ninja Forms is a webform builder with unparalleled ease of use and features.
6
+ Version: 3.4.3
7
  Author: The WP Ninjas
8
  Author URI: http://ninjaforms.com
9
  Text Domain: ninja-forms
58
  * @since 3.0
59
  */
60
 
61
+ const VERSION = '3.4.3';
62
 
63
  /**
64
  * @since 3.4.0
490
  global $wpdb;
491
  $sql = "SELECT COUNT( `id` ) AS total FROM `{$wpdb->prefix}nf3_forms`;";
492
  $result = $wpdb->get_results( $sql, 'ARRAY_A' );
493
+ $threshold = 10; // Threshold percentage for our required updates.
494
  // If we got back a list of updates...
495
  // AND If we have any forms on the site...
496
  // AND If the gate is open...
497
+ // To avoid errors on older upgrades, ignore the gatekeeper if the db version is the baseline (1.0)...
498
  if ( ! empty( $required_updates )
499
  && 0 < $result[ 0 ][ 'total' ]
500
+ && ( WPN_Helper::gated_release( $threshold )
501
+ || '1.0' == self::$db_version ) ) {
502
  // Record that we have updates to run.
503
  update_option( 'ninja_forms_needs_updates', 1 );
504
  } // Otherwise... (Sanity check)
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpninjasllc, kstover, jameslaws, kbjohnson90, klhall1987, krmoorho
3
  Tags: form, forms, contact form, custom form, form builder, form creator, form manager, form creation, contact forms, custom forms, forms builder, forms creator, forms manager, forms creation, form administration,
4
  Requires at least: 4.8
5
  Tested up to: 5.0
6
- Stable tag: 3.4.2
7
  License: GPLv2 or later
8
 
9
  Drag and drop fields in an intuitive UI to create contact forms, email subscription forms, order forms, payment forms, send emails and more!
@@ -111,21 +111,29 @@ For help and video tutorials, please visit our website: [Ninja Forms Documentati
111
 
112
  == Upgrade Notice ==
113
 
114
- = 3.4.2 (17 January 2019) =
115
 
116
  *Bugs:*
117
 
118
- * Resolved an issue that sometimes caused fields to not appear on the form after publish.
119
- * Corrected an error that was causing form duplication to fail.
120
- * Sites with WP_DEBUG enabled should no longer display an undefined 'maintenance' column error on form load.
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
 
 
 
124
  = 3.4.2 (17 January 2019) =
125
 
126
  *Bugs:*
127
 
128
- * Resolved an issue that sometimes caused fields to not appear on the form after publish.
129
 
130
  = 3.4.1 (15 January 2019) =
131
 
3
  Tags: form, forms, contact form, custom form, form builder, form creator, form manager, form creation, contact forms, custom forms, forms builder, forms creator, forms manager, forms creation, form administration,
4
  Requires at least: 4.8
5
  Tested up to: 5.0
6
+ Stable tag: 3.4.3
7
  License: GPLv2 or later
8
 
9
  Drag and drop fields in an intuitive UI to create contact forms, email subscription forms, order forms, payment forms, send emails and more!
111
 
112
  == Upgrade Notice ==
113
 
114
+ = 3.4.3 (5 February 2019) =
115
 
116
  *Bugs:*
117
 
118
+ * Resolved an issue that was causing some form imports to fail.
119
+ * Submission exports of checkbox fields that have been modified by an admin should now display their proper value in the csv.
120
+ * Resolved an issue that was rarely causing actions to fire twice.
121
 
122
  == Changelog ==
123
 
124
+ = 3.4.3 (5 February 2019) =
125
+
126
+ *Bugs:*
127
+
128
+ * Resolved an issue that was causing some form imports to fail.
129
+ * Submission exports of checkbox fields that have been modified by an admin should now display their proper value in the csv.
130
+ * Resolved an issue that was rarely causing actions to fire twice.
131
+
132
  = 3.4.2 (17 January 2019) =
133
 
134
  *Bugs:*
135
 
136
+ * Resolved an issue that sometimes caused fields to not appear on the form after publish. (Special thanks to Tim de Hoog and Sidekick-IT).
137
 
138
  = 3.4.1 (15 January 2019) =
139