Commit 0c4392c7 authored by KR Moorhouse's avatar KR Moorhouse

Merge branch 'develop' into issue#4037

parents 4a5957db 53471145
......@@ -273,17 +273,19 @@ class NF_AJAX_Controllers_Submission extends NF_Abstracts_Controller
$unique_field_value = serialize( $unique_field_value );
}
/*
* Check our db for the value submitted.
*/
global $wpdb;
// @TODO: Rewrite this to use our submissions API.
$sql = $wpdb->prepare( "SELECT COUNT(m.meta_id) FROM `" . $wpdb->prefix . "postmeta` AS m LEFT JOIN `" . $wpdb->prefix . "posts` AS p ON p.id = m.post_id WHERE m.meta_key = '_field_%d' AND m.meta_value = '%s' AND p.post_status = 'publish'", $unique_field_id, $unique_field_value );
$result = $wpdb->get_results( $sql, 'ARRAY_N' );
if ( intval( $result[ 0 ][ 0 ] ) > 0 ) {
$this->_errors['fields'][ $unique_field_id ] = array( 'slug' => 'unique_field', 'message' => $unique_field_error );
$this->_respond();
if ( ! empty($unique_field_value) ) {
/*
* Check our db for the value submitted.
*/
global $wpdb;
// @TODO: Rewrite this to use our submissions API.
$sql = $wpdb->prepare( "SELECT COUNT(m.meta_id) FROM `" . $wpdb->prefix . "postmeta` AS m LEFT JOIN `" . $wpdb->prefix . "posts` AS p ON p.id = m.post_id WHERE m.meta_key = '_field_%d' AND m.meta_value = '%s' AND p.post_status = 'publish'", $unique_field_id, $unique_field_value );
$result = $wpdb->get_results( $sql, 'ARRAY_N' );
if ( intval( $result[ 0 ][ 0 ] ) > 0 ) {
$this->_errors['fields'][ $unique_field_id ] = array( 'slug' => 'unique_field', 'message' => $unique_field_error );
$this->_respond();
}
}
}
......
......@@ -145,7 +145,7 @@ class NF_Admin_Processes_ImportForm extends NF_Abstracts_BatchProcess
public function restart()
{
// Get our remaining fields from the database.
$this->form = get_option( 'nf_import_form', $this->form, array() );
$this->form = get_option( 'nf_import_form', array() );
}
/**
......@@ -169,7 +169,7 @@ class NF_Admin_Processes_ImportForm extends NF_Abstracts_BatchProcess
* Save our processing option.
* Move on to the next step.
*/
if ( ! isset ( $this->form[ 'ID' ] ) ) {
if ( ! isset( $this->form[ 'ID' ] ) ) {
$this->insert_form();
} else { // We have a form ID set.
$this->insert_fields();
......@@ -239,6 +239,8 @@ class NF_Admin_Processes_ImportForm extends NF_Abstracts_BatchProcess
$insert_columns = array();
$insert_columns_types = array();
foreach ( $this->forms_db_columns as $column_name => $setting_name ) {
// Make sure we don't try to set created_at to NULL.
if( 'created_at' === $column_name && is_null( $this->form[ 'settings' ][ $setting_name ] ) ) continue;
$insert_columns[ $column_name ] = $this->form[ 'settings' ][ $setting_name ];
if ( is_numeric( $this->form[ 'settings' ][ $setting_name ] ) ) {
array_push( $insert_columns_types, '%d' );
......@@ -252,6 +254,11 @@ class NF_Admin_Processes_ImportForm extends NF_Abstracts_BatchProcess
// Update our form ID with the newly inserted row ID.
$this->form[ 'ID' ] = $this->_db->insert_id;
if ( 0 === $this->form[ 'ID' ] ) {
$this->add_error( 'insert_failed', __( 'Failed to insert new form.', 'ninja-forms' ), 'fatal' );
$this->batch_complete();
}
$this->insert_form_meta();
$this->insert_actions();
......
......@@ -50,7 +50,7 @@ final class NF_MergeTags_Fields extends NF_Abstracts_MergeTags
if( is_array( $field[ 'value' ] ) ) $field[ 'value' ] = implode( ', ', $field[ 'value' ] );
$return .= '<tr><td>' . apply_filters('ninja_forms_merge_label', $field[ 'label' ]) .':</td><td>' . $field[ 'value' ] . '</td></tr>';
$return .= '<tr><td>' . apply_filters('ninja_forms_merge_label', $field[ 'label' ], $field, $this->form_id) .':</td><td>' . $field[ 'value' ] . '</td></tr>';
}
$return .= '</table>';
return $return;
......@@ -90,7 +90,7 @@ final class NF_MergeTags_Fields extends NF_Abstracts_MergeTags
if( is_array( $field[ 'value' ] ) ) $field[ 'value' ] = implode( ', ', $field[ 'value' ] );
// Check to see if the type is a list field and if it is...
$return .= '<tr><td valign="top">' . apply_filters('ninja_forms_merge_label', $field[ 'label' ]) .':</td><td>' . $field[ 'value' ] . '</td></tr>';
$return .= '<tr><td valign="top">' . apply_filters('ninja_forms_merge_label', $field[ 'label' ], $field, $this->form_id) .':</td><td>' . $field[ 'value' ] . '</td></tr>';
}
$return .= '</table>';
return $return;
......@@ -137,7 +137,7 @@ final class NF_MergeTags_Fields extends NF_Abstracts_MergeTags
if( is_array( $field[ 'value' ] ) ) $field[ 'value' ] = implode( ', ', $field[ 'value' ] );
$return .= '<tr><td valign="top">' . apply_filters('ninja_forms_merge_label', $field[ 'label' ]) .':</td><td>' . $field[ 'value' ] . '</td></tr>';
$return .= '<tr><td valign="top">' . apply_filters('ninja_forms_merge_label', $field[ 'label' ], $field, $this->form_id) .':</td><td>' . $field[ 'value' ] . '</td></tr>';
}
$return .= '</table>';
return $return;
......@@ -248,6 +248,7 @@ final class NF_MergeTags_Fields extends NF_Abstracts_MergeTags
// Loop over our options...
$field[ 'options' ] = apply_filters( 'ninja_forms_render_options', $field[ 'options' ], $field );
$field[ 'options' ] = apply_filters( 'ninja_forms_render_options_' . $field['type'], $field[ 'options' ], $field );
$field[ 'options' ] = apply_filters( 'ninja_forms_localize_list_labels', $field[ 'options' ], $field, $this->form_id );
foreach( $field[ 'options' ] as $options ) {
// ...checks to see if our list has multiple values.
if( is_array( $field[ 'value' ] ) ) {
......
......@@ -1306,14 +1306,6 @@ if( get_option( 'ninja_forms_load_deprecated', FALSE ) && ! ( isset( $_POST[ 'nf
* @since 3.3.17
*/
function nf_update_marketing_feed() {
// Fetch our membership data.
$data = wp_remote_get( 'http://api.ninjaforms.com/feeds/?fetch=memberships' );
// If we got a valid response...
if ( 200 == $data[ 'response' ][ 'code' ] ) {
// Save the data to our option.
$data = wp_remote_retrieve_body( $data );
update_option( 'ninja_forms_memberships_feed', $data, false );
}
// Fetch our addon data.
$data = wp_remote_get( 'http://api.ninjaforms.com/feeds/?fetch=addons' );
// If we got a valid response...
......
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