Commit 2de9b606 authored by Kevin Stover's avatar Kevin Stover

Merge branch 'develop'

# Conflicts:
#	README.md
#	assets/js/front-end/controllers/fieldRecaptcha.js
#	assets/js/min/front-end.js
#	assets/js/min/front-end.js.map
#	deprecated/ninja-forms.php
#	includes/Database/FieldsController.php
#	ninja-forms.php
#	readme.txt
parents 45473198 929ad357
......@@ -4,9 +4,7 @@
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,
Requires at least: 4.5
Tested up to: 4.7.2
Stable tag: 3.0.28
Stable tag: 3.0.29
License: GPLv2 or later
With a simple drag and drop interface you can create contact forms, email subscription forms, order forms, payment forms, and any other type of form for your WordPress site.
......
......@@ -17,8 +17,11 @@ define([], function() {
},
resetRecaptcha: function() {
if ( 'undefined' == typeof grecaptcha ) return false;
try {
grecaptcha.reset();
} catch( e ){
console.log( 'Notice: Error trying to reset grecaptcha.' );
}
}
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -265,7 +265,7 @@ class Ninja_Forms {
// Plugin version
if ( ! defined( 'NF_PLUGIN_VERSION' ) )
define( 'NF_PLUGIN_VERSION', '3.0.28' );
define( 'NF_PLUGIN_VERSION', '3.0.29' );
// Plugin Folder Path
if ( ! defined( 'NF_PLUGIN_DIR' ) )
......
<?php
final class NF_Database_FieldsController
{
private $db;
private $factory;
private $fields_data;
private $new_field_ids;
private $insert_fields;
private $insert_field_meta = array();
private $insert_field_meta_chunk = 0;
private $update_fields = array( 'key' => '', 'label' => '', 'type' => '' );
private $update_field_meta = array();
private $update_field_meta_chunk = 0;
public function __construct( $form_id, $fields_data )
{
global $wpdb;
......@@ -23,38 +18,41 @@ final class NF_Database_FieldsController
$this->form_id = $form_id;
$this->fields_data = $fields_data;
}
public function run()
{
$this->db->hide_errors();
/* FIELDS */
$this->parse_fields();
$this->db->query( $this->get_insert_fields_query() );
$this->db->query( $this->get_update_fields_query() );
$insert_fields_query = $this->get_insert_fields_query();
if( ! empty( $insert_fields_query ) ){
$this->db->query( $insert_fields_query );
$this->update_new_field_ids();
}
$update_fields_query = $this->get_update_fields_query();
if( ! empty( $update_fields_query ) ){
$this->db->query( $update_fields_query );
}
/* FIELD META */
$this->parse_field_meta();
$this->run_insert_field_meta_query();
$this->run_update_field_meta_query();
}
public function get_updated_fields_data()
{
return $this->fields_data;
}
private function parse_fields()
{
foreach( $this->fields_data as $field_data ){
$field_id = $field_data[ 'id' ];
$settings = array(
'key' => $field_data[ 'settings' ][ 'key' ],
'label' => $field_data[ 'settings' ][ 'label' ],
'type' => $field_data[ 'settings' ][ 'type' ]
);
if( is_string( $field_id ) ){
$this->insert_field( $settings ); // New Field.
} else {
......@@ -62,15 +60,11 @@ final class NF_Database_FieldsController
}
}
}
private function parse_field_meta()
{
$existing_meta = $this->get_existing_meta();
foreach( $this->fields_data as $field_data ){
$field_id = $field_data[ 'id' ];
foreach( $field_data[ 'settings' ] as $key => $value ){
if( isset( $existing_meta[ $field_id ][ $key ] ) ){
if( $value == $existing_meta[ $field_id ][ $key ] ) continue;
......@@ -81,7 +75,6 @@ final class NF_Database_FieldsController
}
}
}
private function get_existing_meta()
{
$results = $this->db->get_results("
......@@ -91,7 +84,6 @@ final class NF_Database_FieldsController
ON m.parent_id = f.id
WHERE f.parent_id = {$this->form_id}
");
$field_meta = array();
foreach( $results as $meta ){
if( ! isset( $field_meta[ $meta->parent_id ] ) ) $field_meta[ $meta->parent_id ] = array();
......@@ -99,7 +91,6 @@ final class NF_Database_FieldsController
}
return $field_meta;
}
private function update_new_field_ids()
{
$field_id_lookup = $this->db->get_results("
......@@ -107,9 +98,7 @@ final class NF_Database_FieldsController
FROM {$this->db->prefix}nf3_fields
WHERE `parent_id` = {$this->form_id}
", OBJECT_K);
foreach( $this->fields_data as $i => $field_data ){
$field_key = $field_data[ 'settings' ][ 'key' ];
if( is_string( $field_data[ 'id' ] ) && isset( $field_id_lookup[ $field_key ] ) ){
$tmp_id = $field_data[ 'id' ];
......@@ -117,18 +106,15 @@ final class NF_Database_FieldsController
}
}
}
public function get_new_field_ids()
{
return $this->new_field_ids;
}
/*
|--------------------------------------------------------------------------
| INSERT (NEW) FIELDS
|--------------------------------------------------------------------------
*/
private function insert_field( $settings )
{
$this->insert_fields .= "(";
......@@ -139,7 +125,6 @@ final class NF_Database_FieldsController
$this->insert_fields .= "'{$this->form_id}'";
$this->insert_fields .= '),';
}
public function get_insert_fields_query()
{
if( ! $this->insert_fields ) return "";
......@@ -149,13 +134,11 @@ final class NF_Database_FieldsController
VALUES {$insert_fields}
";
}
/*
|--------------------------------------------------------------------------
| UPDATE (EXISTING) FIELDS
|--------------------------------------------------------------------------
*/
private function update_field( $field_id, $settings )
{
foreach ( $settings as $setting => $value ) {
......@@ -165,7 +148,6 @@ final class NF_Database_FieldsController
$this->update_fields[ $setting ] .= $line;
}
}
public function get_update_fields_query()
{
if(
......@@ -186,27 +168,22 @@ final class NF_Database_FieldsController
END
";
}
/*
|--------------------------------------------------------------------------
| INSERT (NEW) META
|--------------------------------------------------------------------------
*/
private function insert_field_meta( $field_id, $key, $value )
{
static $counter;
$this->db->escape_by_ref( $field_id );
$this->db->escape_by_ref( $key );
$this->db->escape_by_ref( $value );
if( ! $this->insert_field_meta[ $this->insert_field_meta_chunk ] ) $this->insert_field_meta[ $this->insert_field_meta_chunk ] = '';
$this->insert_field_meta[ $this->insert_field_meta_chunk ] .= "('{$field_id}','{$key}','{$value}' ),";
$counter++;
if( 0 == $counter % 5000 ) $this->insert_field_meta_chunk++;
}
public function run_insert_field_meta_query()
{
if( ! $this->insert_field_meta ) return "";
......@@ -218,26 +195,21 @@ final class NF_Database_FieldsController
");
}
}
/*
|--------------------------------------------------------------------------
| UPDATE (EXISTING) META
|--------------------------------------------------------------------------
*/
private function update_field_meta( $field_id, $key, $value )
{
static $counter;
$this->db->escape_by_ref( $key );
$this->db->escape_by_ref( $value );
if( ! $this->update_field_meta[ $this->update_field_meta_chunk ] ) $this->update_field_meta[ $this->update_field_meta_chunk ] = '';
$this->update_field_meta[ $this->update_field_meta_chunk ] .= " WHEN `parent_id` = '{$field_id}' AND 'key' = '{$key}' THEN '{$value}'";
$counter++;
if( 0 == $counter % 5000 ) $this->update_field_meta_chunk++;
}
public function run_update_field_meta_query()
{
if( empty( $this->update_field_meta ) ) return '';
......@@ -249,5 +221,4 @@ final class NF_Database_FieldsController
return;
}
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@
Plugin Name: Ninja Forms
Plugin URI: http://ninjaforms.com/
Description: Ninja Forms is a webform builder with unparalleled ease of use and features.
Version: 3.0.28
Version: 3.0.29
Author: The WP Ninjas
Author URI: http://ninjaforms.com
Text Domain: ninja-forms
......@@ -51,7 +51,7 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
/**
* @since 3.0
*/
const VERSION = '3.0.28';
const VERSION = '3.0.29';
/**
* @var Ninja_Forms
......
......@@ -3,7 +3,7 @@ Contributors: wpninjasllc, kstover, jameslaws, kbjohnson90, klhall1987, wpnzach,
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,
Requires at least: 4.5
Tested up to: 4.7.2
Stable tag: 3.0.28
Stable tag: 3.0.29
License: GPLv2 or later
Drag and drop fields in an intuitive UI to create create contact forms, email subscription forms, order forms, payment forms, send emails and more!
......@@ -102,22 +102,19 @@ For help and video tutorials, please visit our website: [Ninja Forms Documentati
== Upgrade Notice ==
= 3.0.28 (21 February 2017) =
= 3.0.29 (21 February 2017) =
*Bugs:*
* Fixed a JS notice caused by the use of jQuery.attr() instead of jQuery.prop().
* Modified the approach to form publishing to improve performance for larger forms and prevent bugs when saving.
* Google reCaptcha should now work properly when a field has an error.
* Fixed a bug that could cause previewed forms from submitting properly.
*Changes:*
== Changelog ==
* Added a jQuery event: "nfFormReady" to the document that can be used to fire JS code when a form has loaded.
* Using jQuery.val() should now properly work for Ninja Forms fields.
* Updated the update check URL for add-ons.
* Added a filter for form settings upon form display localization.
= 3.0.29 (21 February 2017) =
== Changelog ==
*Bugs:*
* Fixed a bug that could cause previewed forms from submitting properly.
= 3.0.28 (21 February 2017) =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment