Commit 45473198 authored by Kevin Stover's avatar Kevin Stover Committed by Kyle B. Johnson

Release version 3.0.28 (#2450)

* Reverting optimisation changes in favor of a traditional loop. Performance increases in 3.0.25 render the optimisations unnecessary. Closes #2366. (#2372)

* Update email setting reference for better error reporting (#2362)

* update email setting reference for error reporting. Closes #2361.

* Reverting optimisation changes in favor of a traditional loop. Performance increases in 3.0.25 render the optimisations unnecessary. Closes #2366. (#2372)

* Adjusting the invalid email error message.

* Adding logic for fancy emails: Kevin Stover <kevin@wpninjas.com>. Closes #2361.

* Ninja Forms implementation of the WP List Table should only appear on Ninja Forms plugin menus. Closes #2376. (#2378)

* Updating to version 3.0.26. See Changelog for details.

* use uasort to maintain key associations. Closes #2383. (#2384)

* Fixing a malformed radio trigger.

* Using timestamp for key update upon label change. Closes #2387. (#2388)

* Add field sort filter for All Fields merge tag. (#2390)

* add all_fields sorting for add-ons. Closes #2385.

* update fields_by_key parameter.

* set the field ID for the fields merge tag.

* skip the submit button in the all fields table.

* Add password setting type (#2309)

* move reply_to to primary settings. Closes #2290. (#2291)

* Update admin-menu-settings.html.php

* Add initial header advert for Layout & Styles (#2396)

* Added some styling and structure for a new header ad.

* Adding affiliate ID, NF_Layouts() check, Translated banner ad, updated banner ad text, now disables with the "disable admin notices" setting.

* Updating header ad text.

* Updating to version 3.0.27. See Changelog for details.

* Adding filters for form settings on display. (#2431)

* Fixing a bug with rendering.

* Database fields controller (#2444)

* stub out the database fields controller.

* build out db fields controller.

* add id lookup for new fields and return updated fields.

* re-organize db fields controller.

* extract existing meta query to new method.

* return new field ids to the client.

* update field meta update query.

* add early return for incomplete query.

* reduce to single string concatination.

* add query chunking.

* Fixing a bug with defined "wp_" DB prefixes.

* Adding a jQuery event, nfFormReady, to the document. Can be used to run code when a form is ready to manipulate and fully rendered. Closes #2436. (#2437)

* Adding a patch to jQuery.val() that triggers a .change() if the targe… (#2435)

* Adding a patch to jQuery.val() that triggers a .change() if the target is a Ninja Forms field. Closes #2434.

* Removing a console.log

* Changing calls to .attr to .prop. Originally committed by: @h-plus-arry. Closes #1943. (#2445)

* Remove tabindex on help icons + enable focus styling for dropdown (#2419)

* check form cache when calling get_field(). Closes #2413. (#2415)

* Updating store URL to ninjaforms.com/update-check/. (#2408)

* Updating store URL to ninjaforms.com/update-check/.

* Fixing a bug with processing labels for the submit button.

* reset reCaptcha on submission errors. Closes #2306. (#2406)

* Fixing a bug with recaptcha that caused an undefined error.

* Make action table extensible. (#2405)

* make action table extendible.

* add validation bypass.

* add field validation bypass.

* restore progress anim image (#2398)

* add fallback for unserialize UTF8 parse errors. Closes #2393. (#2394)

* Updating to version 3.0.28. See Changelog for details.
parent 57d8e04c
......@@ -4,7 +4,8 @@
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.27
Stable tag: 3.0.28
License: GPLv2 or later
......
......@@ -2,7 +2,7 @@
* Single action table row
*
* TODO: make dynamic
*
*
* @package Ninja Forms builder
* @subpackage Actions
* @copyright (c) 2015 WP Ninjas
......@@ -12,12 +12,13 @@ define( ['views/app/itemControls'], function( itemControlsView ) {
var view = Marionette.LayoutView.extend({
tagName: 'tr',
template: '#tmpl-nf-action-item',
regions: {
itemControls: '.nf-item-controls'
},
initialize: function() {
this.template = nfRadio.channel( 'actions' ).request( 'get:actionItemTemplate' ) || this.template;
this.model.on( 'change:label', this.render, this );
this.model.on( 'change:editActive', this.render, this );
this.model.on( 'change:active', this.maybeDeactivate, this );
......@@ -28,7 +29,7 @@ define( ['views/app/itemControls'], function( itemControlsView ) {
this.model.off( 'change:editActive', this.render );
this.model.off( 'change:active', this.maybeDeactivate );
},
onRender: function() {
if ( this.model.get( 'editActive' ) ) {
jQuery( this.el ).addClass( 'active' );
......@@ -37,7 +38,7 @@ define( ['views/app/itemControls'], function( itemControlsView ) {
}
this.maybeDeactivate();
this.itemControls.show( new itemControlsView( { model: this.model } ) );
},
......@@ -61,18 +62,22 @@ define( ['views/app/itemControls'], function( itemControlsView ) {
},
changeToggle: function( e ) {
var settingModel = nfRadio.channel( 'actions' ).request( 'get:settingModel', 'active' );
var setting = jQuery( e.target ).data( 'setting' );
var settingModel = nfRadio.channel( 'actions' ).request( 'get:settingModel', setting );
console.log( settingModel );
console.log( this.model );
nfRadio.channel( 'app' ).request( 'change:setting', e, settingModel, this.model );
nfRadio.channel( 'app' ).request( 'update:db' );
},
templateHelpers: function() {
return {
renderToggle: function() {
renderToggle: function( settingName ) {
this.settingName = settingName || 'active';
var actionLabel = this.label;
this.label = '';
this.value = this.active;
this.name = this.id + '-active';
this.value = this[ this.settingName ];
this.name = this.id + '-' + this.settingName;
var html = nfRadio.channel( 'app' ).request( 'get:template', '#tmpl-nf-edit-setting-toggle' );
html = html( this );
this.label = actionLabel;
......@@ -82,13 +87,13 @@ define( ['views/app/itemControls'], function( itemControlsView ) {
renderTypeNicename: function() {
var type = nfRadio.channel( 'actions' ).request( 'get:type', this.type );
if ( 'undefined' == typeof type ) return;
return type.get( 'nicename' );
},
renderTooltip: function() {
if ( this.help ) {
return '<a class="nf-help" href="#"><span class="dashicons dashicons-admin-comments"></span></a><div class="nf-help-text">' + this.help + '</div>';
return '<a class="nf-help" href="#" tabindex="-1"><span class="dashicons dashicons-admin-comments"></span></a><div class="nf-help-text">' + this.help + '</div>';
} else {
return '';
}
......@@ -106,4 +111,4 @@ define( ['views/app/itemControls'], function( itemControlsView ) {
});
return view;
} );
\ No newline at end of file
} );
......@@ -2,7 +2,7 @@
* Main content view for our actions.
*
* TODO: make dynamic
*
*
* @package Ninja Forms builder
* @subpackage Actions
* @copyright (c) 2015 WP Ninjas
......@@ -14,6 +14,10 @@ define( ['views/actions/actionItem', 'views/actions/mainContentEmpty'], function
childView: actionView,
emptyView: emptyView,
initialize: function() {
this.template = nfRadio.channel( 'actions' ).request( 'get:mainContentTemplate' ) || this.template;
},
onRender: function() {
jQuery( this.el ).droppable( {
accept: '.nf-action-type-draggable',
......@@ -27,10 +31,10 @@ define( ['views/actions/actionItem', 'views/actions/mainContentEmpty'], function
attachHtml: function( collectionView, childView ) {
if ( 'undefined' == typeof nfRadio.channel( 'actions' ).request( 'get:type', childView.model.get( 'type' ) ) ) return;
jQuery( collectionView.el ).find( 'tbody' ).append( childView.el );
},
});
return view;
} );
\ No newline at end of file
} );
......@@ -250,7 +250,7 @@ define( ['views/app/drawer/mergeTagsContent', 'views/app/drawer/settingError'],
renderTooltip: function() {
if ( this.help ) {
return '<a class="nf-help" href="#"><span class="dashicons dashicons-admin-comments"></span></a><div class="nf-help-text">' + this.help + '</div>';
return '<a class="nf-help" href="#" tabindex="-1"><span class="dashicons dashicons-admin-comments"></span></a><div class="nf-help-text">' + this.help + '</div>';
} else {
return '';
}
......
......@@ -13,7 +13,7 @@ define([], function() {
},
beforeUpdateField: function( el, model ) {
var checked = jQuery( el ).attr( 'checked' );
var checked = jQuery( el ).prop( 'checked' );
if ( checked ) {
var value = 1;
jQuery( el ).addClass( 'nf-checked' );
......
......@@ -118,7 +118,7 @@ define([], function() {
if ( typeof selected == 'string' ) selected = [ selected ];
var value = jQuery( el ).val();
var checked = jQuery( el ).attr( 'checked' );
var checked = jQuery( el ).prop( 'checked' );
if ( checked ) {
selected.push( value );
jQuery( el ).addClass( 'nf-checked' );
......
......@@ -2,7 +2,8 @@ define([], function() {
var controller = Marionette.Object.extend({
initialize: function () {
this.listenTo( nfRadio.channel( 'recaptcha' ), 'init:model', this.initRecaptcha );
this.listenTo( nfRadio.channel( 'recaptcha' ), 'init:model', this.initRecaptcha );
this.listenTo( nfRadio.channel( 'forms' ), 'submit:response', this.resetRecaptcha );
},
initRecaptcha: function ( model ) {
......@@ -13,8 +14,13 @@ define([], function() {
updateResponse: function( response ) {
this.model.set( 'value', response );
nfRadio.channel( 'fields' ).request( 'remove:error', this.model.get( 'id' ), 'required-error' );
},
resetRecaptcha: function() {
if ( 'undefined' == typeof grecaptcha ) return false;
grecaptcha.reset();
}
});
return controller;
} );
\ No newline at end of file
} );
......@@ -9,7 +9,7 @@ define([], function() {
/**
* Register the submission handler function.
*
*
* @since 3.0
* @param Backbone.model formModel
* @return void
......@@ -26,7 +26,7 @@ define([], function() {
* 2) Check the form for errors
* 3) Submit the data
* 4) Send out a message with our response
*
*
* @since 3.0
* @param Backbone.model formModel
* @return void
......@@ -39,29 +39,36 @@ define([], function() {
*/
nfRadio.channel( 'forms' ).trigger( 'before:submit', formModel );
nfRadio.channel( 'form-' + formModel.get( 'id' ) ).trigger( 'before:submit', formModel );
/*
* Validate our field models.
*
* This method is defined in our models/fieldCollection.js file.
*/
formModel.get( 'formContentData' ).validateFields();
var validate = nfRadio.channel( 'forms' ).request( 'maybe:validate', formModel );
if( false !== validate ){
var submit = nfRadio.channel( 'form-' + formModel.get( 'id' ) ).request( 'maybe:submit', formModel );
/*
* This method is defined in our models/fieldCollection.js file.
*/
formModel.get( 'formContentData' ).validateFields();
}
var submit = nfRadio.channel( 'form-' + formModel.get( 'id' ) ).request( 'maybe:submit', formModel );
if ( false == submit ) {
nfRadio.channel( 'forms' ).trigger( 'submit:cancel', formModel );
nfRadio.channel( 'form-' + formModel.get( 'id' ) ).trigger( 'submit:cancel', formModel );
return;
}
/*
* Make sure we don't have any form errors before we submit.
* Return false if we do.
*/
if ( 0 != _.size( formModel.get( 'fieldErrors' ) ) ) {
nfRadio.channel( 'forms' ).trigger( 'submit:failed', formModel );
nfRadio.channel( 'form-' + formModel.get( 'id' ) ).trigger( 'submit:failed', formModel );
return false;
if( false !== validate ){
/*
* Make sure we don't have any form errors before we submit.
* Return false if we do.
*/
if ( 0 != _.size( formModel.get( 'fieldErrors' ) ) ) {
nfRadio.channel( 'forms' ).trigger( 'submit:failed', formModel );
nfRadio.channel( 'form-' + formModel.get( 'id' ) ).trigger( 'submit:failed', formModel );
return false;
}
}
/*
......@@ -106,7 +113,9 @@ define([], function() {
nfRadio.channel( 'forms' ).trigger( 'submit:response', response, textStatus, jqXHR, formModel.get( 'id' ) );
nfRadio.channel( 'form-' + formModel.get( 'id' ) ).trigger( 'submit:response', response, textStatus, jqXHR );
} catch( e ) {
console.log( e );
console.log( 'Parse Error' );
console.log( e );
}
},
......@@ -133,4 +142,4 @@ define([], function() {
});
return controller;
} );
\ No newline at end of file
} );
......@@ -54,6 +54,8 @@ define(['controllers/submitButton'], function( submitButton ) {
},
processingLabel: function() {
if ( this.get( 'label' ) == this.get( 'processing_label' ) ) return false;
this.set( 'oldLabel', this.get( 'label' ) );
this.set( 'label', this.get( 'processing_label' ) );
this.trigger( 'reRender' );
......
/*
* Because our backbone listens to .change() events on elements, changes made using jQuery .val() don't bubble properly.
* This patch overwrites the default behaviour of jQuery .val() so that IF the item has an nf-element class, we fire a change event.
*/
( function( jQuery ) {
/*
* Store our original .val() function.
*/
var originalVal = jQuery.fn.val;
/*
* Create our own .val() function.
*/
jQuery.fn.val = function(){
var prev;
/*
* Store a copy of the results of the original .val() call.
* We use this to make sure that we've actually changed something.
*/
if( arguments.length > 0 ){
prev = originalVal.apply( this,[] );
}
/*
* Get the results of the original .val() call.
*/
var result = originalVal.apply( this, arguments );
/*
* If we have arguments, we have actually made a change, AND this has the nf-element class, trigger .change().
*/
if( arguments.length > 0 && prev != originalVal.apply( this, [] ) && jQuery( this ).hasClass( 'nf-element' ) ) {
jQuery(this).change();
}
return result;
};
} ) ( jQuery );
jQuery( document ).ready( function( $ ) {
require( [ 'models/formCollection', 'models/formModel', 'models/fieldCollection', 'controllers/loadControllers', 'views/mainLayout'], function( formCollection, FormModel, FieldCollection, LoadControllers, mainLayout ) {
......@@ -29,6 +66,7 @@ jQuery( document ).ready( function( $ ) {
_.each( formCollection.models, function( form, index ) {
var layoutView = new mainLayout( { model: form, fieldCollection: form.get( 'fields' ) } );
nfRadio.channel( 'form' ).trigger( 'render:view', layoutView );
jQuery( document ).trigger( 'nfFormReady', layoutView );
} );
},
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
File mode changed from 100755 to 100644
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.
......@@ -6,7 +6,6 @@
//background: #f9f9f9;
background: transparent;
border: 0;
box-shadow: 0 0 0;
margin-top: 7px;
height: 41px !important;
padding: 0 30px 0 15px;
......
......@@ -20,7 +20,7 @@ class NF_Extension_Updater
public $product_nice_name = '';
public $product_name = '';
public $version = '';
public $store_url = 'https://ninjaforms.com';
public $store_url = 'https://ninjaforms.com/update-check/';
public $file = '';
public $author = '';
public $error = '';
......
......@@ -265,8 +265,7 @@ class Ninja_Forms {
// Plugin version
if ( ! defined( 'NF_PLUGIN_VERSION' ) )
define( 'NF_PLUGIN_VERSION', '3.0.27' );
define( 'NF_PLUGIN_VERSION', '3.0.28' );
// Plugin Folder Path
if ( ! defined( 'NF_PLUGIN_DIR' ) )
......
......@@ -41,33 +41,10 @@ class NF_AJAX_Controllers_Form extends NF_Abstracts_Controller
$form->update_settings( $form_data[ 'settings' ] )->save();
if( isset( $form_data[ 'fields' ] ) ) {
foreach ($form_data['fields'] as &$field_data) {
if( 'unknown' == $field_data[ 'settings' ][ 'type' ] ) continue;
$id = $field_data['id'];
$field = Ninja_Forms()->form( $form_data[ 'id' ] )->get_field($id);
if ($field->get_tmp_id()) {
$field->save();
$tmp_id = $field->get_tmp_id();
$this->_data['new_ids']['fields'][$tmp_id] = $field->get_id();
$field_data[ 'id' ] = $field->get_id();
}
$this->publish_processing->push_to_queue( array(
'id' => $field->get_id(),
'type' => 'field',
'settings' => $field_data[ 'settings' ]
));
$this->_data[ 'fields' ][ $field->get_id() ] = $field->get_settings();
}
$this->publish_processing->save()->dispatch();
$db_fields_controller = new NF_Database_FieldsController( $form_data[ 'id' ], $form_data[ 'fields' ] );
$db_fields_controller->run();
$form_data[ 'fields' ] = $db_fields_controller->get_updated_fields_data();
$this->_data['new_ids']['fields'] = $db_fields_controller->get_new_field_ids();
}
if( isset( $form_data[ 'deleted_fields' ] ) ){
......
......@@ -111,6 +111,7 @@ class NF_AJAX_Controllers_Submission extends NF_Abstracts_Controller
* For performance reasons, this should be the only time that the fields array is traversed.
* Anything needing to loop through fields should integrate here.
*/
$validate_fields = apply_filters( 'ninja_forms_validate_fields', true, $this->_data );
foreach( $form_fields as $key => $field ){
if( is_object( $field ) ) {
......@@ -156,7 +157,9 @@ class NF_AJAX_Controllers_Submission extends NF_Abstracts_Controller
$field = array_merge( $field, $field[ 'settings' ] );
/** Validate the Field */
$this->validate_field( $field );
if( $validate_fields ){
$this->validate_field( $field );
}
/** Process the Field */
$this->process_field( $field );
......
......@@ -175,9 +175,30 @@ class NF_Abstracts_ModelFactory
*/
public function get_field( $id )
{
$form_id = $this->_object->get_id();
if( isset( $this->_fields[ $id ] ) ){
return $this->_fields[ $id ];
}
/* MISSING FORM ID FALLBACK */
/*
if( ! $form_id ){
$form_id = $wpdb->get_var( $wpdb->prepare(
"SELECT parent_id from {$wpdb->prefix}nf3_fields WHERE id = %d", $id
));
$this->_object = $this->_form = new NF_Database_Models_Form( $this->_db, $id );
}
*/
if( ! $this->_fields ){
$this->get_fields();
}
if( ! isset( $this->_fields[ $id ] ) ){
$form_id = $this->_object->get_id();
$this->_fields[ $id ] = new NF_Database_Models_Field( $this->_db, $id, $form_id );
}
return $this->_fields[ $id ] = new NF_Database_Models_Field( $this->_db, $id, $form_id );
return $this->_fields[ $id ];
}
/**
......@@ -209,7 +230,7 @@ class NF_Abstracts_ModelFactory
}
} else {
foreach( $form_cache[ 'fields' ] as $cached_field ){
$field = Ninja_Forms()->form( $form_id )->get_field( $cached_field[ 'id' ] );
$field = new NF_Database_Models_Field( $this->_db, $cached_field[ 'id' ], $form_id );
$field->update_settings( $cached_field[ 'settings' ] );
$this->_fields[$field->get_id()] = $field;
$field_by_key[ $field->get_setting( 'key' ) ] = $field;
......
<?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;
$this->db = $wpdb;
$this->form_id = $form_id;
$this->fields_data = $fields_data;
}
public function run()
{
/* FIELDS */
$this->parse_fields();
$this->db->query( $this->get_insert_fields_query() );
$this->db->query( $this->get_update_fields_query() );
$this->update_new_field_ids();
/* 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 {
$this->update_field( $field_id, $settings );
}
}
}
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;
$this->update_field_meta( $field_id, $key, $value );
} else {
$this->insert_field_meta( $field_id, $key, $value );
}
}
}
}
private function get_existing_meta()
{
$results = $this->db->get_results("
SELECT m.parent_id, m.key, m.value
FROM `{$this->db->prefix}nf3_field_meta` AS m
LEFT JOIN `{$this->db->prefix}nf3_fields` AS f
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();
$field_meta[ $meta->parent_id ][ $meta->key ] = $meta->value;
}
return $field_meta;
}
private function update_new_field_ids()
{
$field_id_lookup = $this->db->get_results("
SELECT `key`, `id`
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' ];
$this->fields_data[ $i ][ 'id' ] = $this->new_field_ids[ $tmp_id ] = $field_id_lookup[ $field_key ]->id;
}
}
}
public function get_new_field_ids()
{
return $this->new_field_ids;
}
/*
|--------------------------------------------------------------------------
| INSERT (NEW) FIELDS
|--------------------------------------------------------------------------
*/
private function insert_field( $settings )
{
$this->insert_fields .= "(";
foreach ( $settings as $setting => $value ) {
$this->db->escape_by_ref( $value );
$this->insert_fields .= "'{$value}',";
}
$this->insert_fields .= "'{$this->form_id}'";
$this->insert_fields .= '),';
}
public function get_insert_fields_query()
{
if( ! $this->insert_fields ) return "";
$insert_fields = rtrim( $this->insert_fields, ',' ); // Strip trailing comma from SQl.
return "
INSERT INTO {$this->db->prefix}nf3_fields ( `key`, `label`, `type`, `parent_id` )
VALUES {$insert_fields}
";
}
/*
|--------------------------------------------------------------------------
| UPDATE (EXISTING) FIELDS
|--------------------------------------------------------------------------
*/
private function update_field( $field_id, $settings )
{
foreach ( $settings as $setting => $value ) {
$line = "WHEN `id` = '{$field_id}' ";
$this->db->escape_by_ref( $value );
$line .= "THEN '{$value}'";
$this->update_fields[ $setting ] .= $line;
}
}
public function get_update_fields_query()
{
if(
empty( $this->update_fields[ 'key' ] ) ||
empty( $this->update_fields[ 'label' ] ) ||
empty( $this->update_fields[ 'type' ] )
) return "";
return "
UPDATE {$this->db->prefix}nf3_fields
SET `key` = CASE {$this->update_fields[ 'key' ]}
ELSE `key`
END
, `label` = CASE {$this->update_fields[ 'label' ]}
ELSE `label`
END
, `type` = CASE {$this->update_fields[ 'type' ]}
ELSE `type`
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 "";
foreach( $this->insert_field_meta as $insert_field_meta ){
$insert_field_meta = rtrim( $insert_field_meta, ',' ); // Strip trailing comma from SQl.
$this->db->query( "
INSERT INTO {$this->db->prefix}nf3_field_meta ( `parent_id`, `key`, `value` )
VALUES {$insert_field_meta}
");
}
}
/*
|--------------------------------------------------------------------------
| 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 );