Edit File by line
/home/barbar84/www/wp-conte.../plugins/ninja-fo.../includes/Admin/Processe...
File: ImportFormTemplate.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Abstracts_Batch_Process
[3] Fix | Delete
*/
[4] Fix | Delete
class NF_Admin_Processes_ImportFormTemplate extends NF_Admin_Processes_ImportForm
[5] Fix | Delete
{
[6] Fix | Delete
protected $_slug = 'import_form_template';
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Function to run any setup steps necessary to begin processing.
[10] Fix | Delete
*/
[11] Fix | Delete
public function startup()
[12] Fix | Delete
{
[13] Fix | Delete
global $wpdb;
[14] Fix | Delete
[15] Fix | Delete
// If we haven't been passed a template as extraData, then bail.
[16] Fix | Delete
if ( ! isset ( $_POST[ 'extraData' ][ 'template' ] ) || empty ( $_POST[ 'extraData' ][ 'template' ] ) ) {
[17] Fix | Delete
$this->batch_complete();
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
$template_file_name = WPN_Helper::esc_html($_POST[ 'extraData' ][ 'template' ]);
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* If our template_file_name is set to 'new', then respond with 'new' as our form id.
[24] Fix | Delete
*
[25] Fix | Delete
* This will redirect to the builder with a new form.
[26] Fix | Delete
*/
[27] Fix | Delete
if ( 'new' == $template_file_name ) {
[28] Fix | Delete
$this->form[ 'ID' ] = 'new';
[29] Fix | Delete
$this->batch_complete();
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
// Grab the data from the appropriate file location.
[33] Fix | Delete
$registered_templates = Ninja_Forms::config( 'NewFormTemplates' );
[34] Fix | Delete
[35] Fix | Delete
if( isset( $registered_templates[ $template_file_name ] ) && ! empty( $registered_templates[ $template_file_name ][ 'form' ] ) ) {
[36] Fix | Delete
$form_data = $registered_templates[ $template_file_name ][ 'form' ];
[37] Fix | Delete
} else {
[38] Fix | Delete
$form_data = Ninja_Forms::template( $template_file_name . '.nff', array(), TRUE );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* If we don't have any form data, run cleanup.
[43] Fix | Delete
*
[44] Fix | Delete
* TODO: We probably need to show an error to the user here.
[45] Fix | Delete
*/
[46] Fix | Delete
if( ! $form_data ) {
[47] Fix | Delete
$this->cleanup();
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
$this->form = json_decode( html_entity_decode( $form_data ), true );
[51] Fix | Delete
[52] Fix | Delete
// Determine how many steps this will take.
[53] Fix | Delete
$this->response[ 'step_total' ] = $this->get_steps();
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Check to see if we've got new field columns.
[57] Fix | Delete
*
[58] Fix | Delete
* We do this here instead of the get_sql_queries() method so that we don't hit the db multiple times.
[59] Fix | Delete
*/
[60] Fix | Delete
$sql = "SHOW COLUMNS FROM {$wpdb->prefix}nf3_fields LIKE 'field_key'";
[61] Fix | Delete
$results = $wpdb->get_results( $sql );
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* If we don't have the field_key column, we need to remove our new columns.
[65] Fix | Delete
*
[66] Fix | Delete
* Also, set our db stage 1 tracker to false.
[67] Fix | Delete
*/
[68] Fix | Delete
if ( empty ( $results ) ) {
[69] Fix | Delete
unset( $this->actions_db_columns[ 'label' ] );
[70] Fix | Delete
$db_stage_one_complete = false;
[71] Fix | Delete
} else {
[72] Fix | Delete
// Add a form value that stores whether or not we have our new DB columns.
[73] Fix | Delete
$db_stage_one_complete = true;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
$this->form[ 'db_stage_one_complete' ] = $db_stage_one_complete;
[77] Fix | Delete
[78] Fix | Delete
add_option( 'nf_doing_' . $this->_slug, 'true', false );
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function