Commit 0550948a authored by Kyle B. Johnson's avatar Kyle B. Johnson Committed by GitHub

Version bump v3.0.7

* Publish refactor for large data loads

* remove model construct queries. Defer settings query.

* include wp-background-processing.

* add background processing class.

* offload field setting updates.

* refactor model to check form cache before database.

* use form data as form cache.

* version bump v3.0.7.
parent 213f71f0
......@@ -4,7 +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.4
Tested up to: 4.6
Stable tag: 3.0.6
Stable tag: 3.0.7
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.
......
......@@ -265,7 +265,7 @@ class Ninja_Forms {
// Plugin version
if ( ! defined( 'NF_PLUGIN_VERSION' ) )
define( 'NF_PLUGIN_VERSION', '3.0.6' );
define( 'NF_PLUGIN_VERSION', '3.0.7' );
// Plugin Folder Path
if ( ! defined( 'NF_PLUGIN_DIR' ) )
......
......@@ -2,12 +2,21 @@
class NF_AJAX_Controllers_Form extends NF_Abstracts_Controller
{
private $publish_processing;
public function __construct()
{
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
add_action( 'wp_ajax_nf_save_form', array( $this, 'save' ) );
add_action( 'wp_ajax_nf_delete_form', array( $this, 'delete' ) );
}
public function plugins_loaded()
{
$this->publish_processing = new NF_Database_PublishProcessing();
}
public function save()
{
check_ajax_referer( 'ninja_forms_builder_nonce', 'security' );
......@@ -32,6 +41,7 @@ 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;
......@@ -40,16 +50,23 @@ class NF_AJAX_Controllers_Form extends NF_Abstracts_Controller
$field = Ninja_Forms()->form( $form_data[ 'id' ] )->get_field($id);
$field->update_settings( $field_data['settings'] )->save();
if ($field->get_tmp_id()) {
$field->save();
$tmp_id = $field->get_tmp_id();
$this->_data['new_ids']['fields'][$tmp_id] = $field->get_id();
}
$this->publish_processing->push_to_queue( array(
'id' => $field->get_id(),
'type' => 'field',
'settings' => $field_data[ 'settings' ]
));
$this->_data[ 'fields' ][ $id ] = $field->get_settings();
}
$this->publish_processing->save()->dispatch();
}
if( isset( $form_data[ 'deleted_fields' ] ) ){
......@@ -127,6 +144,7 @@ class NF_AJAX_Controllers_Form extends NF_Abstracts_Controller
}
delete_user_option( get_current_user_id(), 'nf_form_preview_' . $form_data['id'] );
update_option( 'nf_form_' . $form_data[ 'id' ], $form_data );
do_action( 'ninja_forms_save_form', $form->get_id() );
......
......@@ -152,33 +152,13 @@ class NF_Abstracts_Model
if( is_numeric( $id ) ) {
$this->_id = absint( $id );
} elseif( $id ) {
$field = $this->_db->get_row( $this->_db->prepare(
"
SELECT `id`
FROM `$this->_table_name`
WHERE `key` = %s
"
, $id )
);
if( $field ){
$this->_id = $field->id;
} else {
$this->_tmp_id = $id;
}
$this->_tmp_id = $id;
}
/*
* Set the Parent ID for context
*/
$this->_parent_id = $parent_id;
/*
* With the ID set, query settings from the database
*/
$this->_settings = $this->get_settings();
}
/**
......@@ -240,6 +220,23 @@ class NF_Abstracts_Model
// If the ID is not set, then we cannot pull settings from the Database.
if( ! $this->_id ) return $this->_settings;
$form_cache = get_option( 'nf_form_' . $this->_parent_id );
if( $form_cache ){
if( 'field'== $this->_type ) {
if (isset($form_cache[ 'fields' ])) {
foreach ($form_cache[ 'fields' ] as $object_id => $object) {
if ($this->_id != $object_id) continue;
$this->update_settings($object['settings']);
break;
}
}
}
}
// Only query if settings haven't been already queried or cache is FALSE.
if( ! $this->_settings || ! $this->_cache ) {
......
<?php if ( ! defined( 'ABSPATH' ) ) exit;
require_once Ninja_Forms::$dir . 'includes/Libraries/BackgroundProcessing/wp-background-processing.php';
final class NF_Database_PublishProcessing extends WP_Background_Process
{
protected $action = 'ninja-forms-publish';
protected function task( $item )
{
if( ! isset( $item[ 'id' ] ) ) return false;
if( ! isset( $item[ 'type' ] ) ) return false;
if( ! isset( $item[ 'settings' ] ) ) return false;
switch ( $item[ 'type' ] ){
case 'field':
$object = Ninja_Forms()->form()->get_field( $item[ 'id' ] );
break;
default:
return false;
}
$object->update_settings( $item[ 'settings' ] )->save();
return false;
}
}
\ No newline at end of file
<?php
/**
* WP Async Request
*
* @package WP-Background-Processing
*/
if ( ! class_exists( 'WP_Async_Request' ) ) {
/**
* Abstract WP_Async_Request class.
*
* @abstract
*/
abstract class WP_Async_Request {
/**
* Prefix
*
* (default value: 'wp')
*
* @var string
* @access protected
*/
protected $prefix = 'wp';
/**
* Action
*
* (default value: 'async_request')
*
* @var string
* @access protected
*/
protected $action = 'async_request';
/**
* Identifier
*
* @var mixed
* @access protected
*/
protected $identifier;
/**
* Data
*
* (default value: array())
*
* @var array
* @access protected
*/
protected $data = array();
/**
* Initiate new async request
*/
public function __construct() {
$this->identifier = $this->prefix . '_' . $this->action;
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
}
/**
* Set data used during the request
*
* @param array $data Data.
*
* @return $this
*/
public function data( $data ) {
$this->data = $data;
return $this;
}
/**
* Dispatch the async request
*
* @return array|WP_Error
*/
public function dispatch() {
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
$args = $this->get_post_args();
return wp_remote_post( esc_url_raw( $url ), $args );
}
/**
* Get query args
*
* @return array
*/
protected function get_query_args() {
if ( property_exists( $this, 'query_args' ) ) {
return $this->query_args;
}
return array(
'action' => $this->identifier,
'nonce' => wp_create_nonce( $this->identifier ),
);
}
/**
* Get query URL
*
* @return string
*/
protected function get_query_url() {
if ( property_exists( $this, 'query_url' ) ) {
return $this->query_url;
}
return admin_url( 'admin-ajax.php' );
}
/**
* Get post args
*
* @return array
*/
protected function get_post_args() {
if ( property_exists( $this, 'post_args' ) ) {
return $this->post_args;
}
return array(
'timeout' => 0.01,
'blocking' => false,
'body' => $this->data,
'cookies' => $_COOKIE,
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
);
}
/**
* Maybe handle
*
* Check for correct nonce and pass to handler.
*/
public function maybe_handle() {
// Don't lock up other requests while processing
session_write_close();
check_ajax_referer( $this->identifier, 'nonce' );
$this->handle();
wp_die();
}
/**
* Handle
*
* Override this method to perform any actions required
* during the async request.
*/
abstract protected function handle();
}
}
<?php
/**
* WP-Background Processing
*
* @package WP-Background-Processing
*/
/*
Plugin Name: WP Background Processing
Plugin URI: https://github.com/A5hleyRich/wp-background-processing
Description: Asynchronous requests and background processing in WordPress.
Author: Delicious Brains Inc.
Version: 1.0
Author URI: https://deliciousbrains.com/
GitHub Plugin URI: https://github.com/A5hleyRich/wp-background-processing
GitHub Branch: master
*/
require_once plugin_dir_path( __FILE__ ) . 'classes/wp-async-request.php';
require_once plugin_dir_path( __FILE__ ) . 'classes/wp-background-process.php';
......@@ -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.6
Version: 3.0.7
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.6';
const VERSION = '3.0.7';
/**
* @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.4
Tested up to: 4.6.1
Stable tag: 3.0.6
Stable tag: 3.0.7
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,28 +102,19 @@ For help and video tutorials, please visit our website: [Ninja Forms Documentati
== Upgrade Notice ==
= 3.0.6 (27 September 2016) =
= 3.0.7 (06 October 2016) =
*Changes:*
* Added the $post variable to the submission info metabox.
* Suppressed HTML fields from submission data.
* Suppressed HTML fields from all fields merge tags
* Added description text to the Rollback Setting (Advanced).
* Disabled the "Edit" page link when previewing a form.
* Added a plugin wide currency setting in place of the static currency symbol setting.
* Added background processing for publishing long forms to avoid timeout errors.
*Bugs:*
== Changelog ==
* Fixed a bug with validating email addresses (ie properly evaluate "+"s).
* Fixed a bug with browser compatibility.
* Fixed a bug with displaying column content on other post types.
* Fixed a bug with updating form submission error messages.
* Fixed a bug with creating empty settings on activation.
* Fixed a bug with column class collisions in CSS.
* Fixed a bug with field help text not displaying on the form.
= 3.0.7 (06 October 2016) =
== Changelog ==
*Changes:*
* Added background processing for publishing long forms to avoid timeout errors.
= 3.0.6 (27 September 2016) =
......
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