Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../includes/Database/Models
File: Form.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Class NF_Database_Models_Form
[3] Fix | Delete
*/
[4] Fix | Delete
final class NF_Database_Models_Form extends NF_Abstracts_Model
[5] Fix | Delete
{
[6] Fix | Delete
protected $_type = 'form';
[7] Fix | Delete
[8] Fix | Delete
protected $_table_name = 'nf3_forms';
[9] Fix | Delete
[10] Fix | Delete
protected $_meta_table_name = 'nf3_form_meta';
[11] Fix | Delete
[12] Fix | Delete
protected $_columns = array(
[13] Fix | Delete
'title',
[14] Fix | Delete
'created_at',
[15] Fix | Delete
'form_title',
[16] Fix | Delete
'default_label_pos',
[17] Fix | Delete
'show_title',
[18] Fix | Delete
'clear_complete',
[19] Fix | Delete
'hide_complete',
[20] Fix | Delete
'logged_in',
[21] Fix | Delete
'seq_num'
[22] Fix | Delete
);
[23] Fix | Delete
[24] Fix | Delete
protected $_fields;
[25] Fix | Delete
[26] Fix | Delete
protected static $imported_form_id;
[27] Fix | Delete
[28] Fix | Delete
public function __construct( $db, $id = '' )
[29] Fix | Delete
{
[30] Fix | Delete
add_action( 'ninja_forms_before_import_form', array( $this, 'import_form_backwards_compatibility' ) );
[31] Fix | Delete
parent::__construct( $db, $id );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
public function delete()
[35] Fix | Delete
{
[36] Fix | Delete
parent::delete();
[37] Fix | Delete
[38] Fix | Delete
$fields = Ninja_Forms()->form( $this->_id )->get_fields();
[39] Fix | Delete
[40] Fix | Delete
foreach( $fields as $field ){
[41] Fix | Delete
$field->delete();
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
$actions = Ninja_Forms()->form( $this->_id )->get_actions();
[45] Fix | Delete
[46] Fix | Delete
foreach( $actions as $action ){
[47] Fix | Delete
$action->delete();
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
$chunked_option_flag = 'nf_form_' . $this->_id . '_chunks';
[51] Fix | Delete
$chunked_option_value = get_option( $chunked_option_flag );
[52] Fix | Delete
// if there is nf_form_x_chunks option, we need to delete those
[53] Fix | Delete
if( $chunked_option_value ) {
[54] Fix | Delete
// if we have chunk'd it, get the list of chunks
[55] Fix | Delete
$form_chunks = explode( ',', $chunked_option_value );
[56] Fix | Delete
[57] Fix | Delete
//get the option value of each chunk and concat them into the form
[58] Fix | Delete
foreach( $form_chunks as $chunk ){
[59] Fix | Delete
delete_option( $chunk );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
delete_option( $chunked_option_flag );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
$this->delete_submissions();
[66] Fix | Delete
[67] Fix | Delete
WPN_Helper::delete_nf_cache( $this->_id );
[68] Fix | Delete
[69] Fix | Delete
do_action( 'ninja_forms_after_form_delete', $this->_id );
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
private function delete_submissions( ) {
[73] Fix | Delete
global $wpdb;
[74] Fix | Delete
$total_subs_deleted = 0;
[75] Fix | Delete
$post_result = 0;
[76] Fix | Delete
$max_cnt = 250;
[77] Fix | Delete
[78] Fix | Delete
// SQL for getting 250 subs at a time
[79] Fix | Delete
$sub_sql = "SELECT id FROM `" . $wpdb->prefix . "posts` AS p
[80] Fix | Delete
LEFT JOIN `" . $wpdb->prefix . "postmeta` AS m ON p.id = m.post_id
[81] Fix | Delete
WHERE p.post_type = 'nf_sub' AND m.meta_key = '_form_id'
[82] Fix | Delete
AND m.meta_value = %s LIMIT " . $max_cnt;
[83] Fix | Delete
[84] Fix | Delete
while ($post_result <= $max_cnt ) {
[85] Fix | Delete
$subs = $wpdb->get_col( $wpdb->prepare( $sub_sql, $this->_id ),0 );
[86] Fix | Delete
// if we are out of subs, then stop
[87] Fix | Delete
if( 0 === count( $subs ) ) break;
[88] Fix | Delete
// otherwise, let's delete the postmeta as well
[89] Fix | Delete
$delete_meta_query = "DELETE FROM `" . $wpdb->prefix . "postmeta` WHERE post_id IN ( [IN] )";
[90] Fix | Delete
$delete_meta_query = $this->prepare_in( $delete_meta_query, $subs );
[91] Fix | Delete
$meta_result = $wpdb->query( $delete_meta_query );
[92] Fix | Delete
if ( $meta_result > 0 ) {
[93] Fix | Delete
// now we actually delete the posts(nf_sub)
[94] Fix | Delete
$delete_post_query = "DELETE FROM `" . $wpdb->prefix . "posts` WHERE id IN ( [IN] )";
[95] Fix | Delete
$delete_post_query = $this->prepare_in( $delete_post_query, $subs );
[96] Fix | Delete
$post_result = $wpdb->query( $delete_post_query );
[97] Fix | Delete
$total_subs_deleted = $total_subs_deleted + $post_result;
[98] Fix | Delete
[99] Fix | Delete
}
[100] Fix | Delete
}
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
private function prepare_in( $sql, $vals ) {
[104] Fix | Delete
global $wpdb;
[105] Fix | Delete
$not_in_count = substr_count( $sql, '[IN]' );
[106] Fix | Delete
if ( $not_in_count > 0 ) {
[107] Fix | Delete
$args = array( str_replace( '[IN]', implode( ', ', array_fill( 0, count( $vals ), '%d' ) ), str_replace( '%', '%%', $sql ) ) );
[108] Fix | Delete
// This will populate ALL the [IN]'s with the $vals, assuming you have more than one [IN] in the sql
[109] Fix | Delete
for ( $i=0; $i < substr_count( $sql, '[IN]' ); $i++ ) {
[110] Fix | Delete
$args = array_merge( $args, $vals );
[111] Fix | Delete
}
[112] Fix | Delete
$sql = call_user_func_array( array( $wpdb, 'prepare' ), array_merge( $args ) );
[113] Fix | Delete
}
[114] Fix | Delete
return $sql;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
public static function get_next_sub_seq( $form_id )
[118] Fix | Delete
{
[119] Fix | Delete
global $wpdb;
[120] Fix | Delete
[121] Fix | Delete
// TODO: Leverage form cache.
[122] Fix | Delete
[123] Fix | Delete
$last_seq_num = $wpdb->get_var( $wpdb->prepare(
[124] Fix | Delete
'SELECT value FROM ' . $wpdb->prefix . 'nf3_form_meta WHERE `key` = "_seq_num" AND `parent_id` = %s'
[125] Fix | Delete
, $form_id ) );
[126] Fix | Delete
[127] Fix | Delete
if( $last_seq_num ) {
[128] Fix | Delete
$wpdb->update( $wpdb->prefix . 'nf3_form_meta', array( 'value' => $last_seq_num + 1,
[129] Fix | Delete
'meta_value' => $last_seq_num + 1, 'meta_key' => '_seq_num' )
[130] Fix | Delete
, array( 'key' => '_seq_num', 'parent_id'
[131] Fix | Delete
=> $form_id ) );
[132] Fix | Delete
$wpdb->update( $wpdb->prefix . 'nf3_forms', array( 'seq_num' => $last_seq_num + 1 ), array( 'id' => $form_id ) );
[133] Fix | Delete
} else {
[134] Fix | Delete
$last_seq_num = 1;
[135] Fix | Delete
$wpdb->insert( $wpdb->prefix . 'nf3_form_meta',
[136] Fix | Delete
array( 'key' => '_seq_num',
[137] Fix | Delete
'value' => $last_seq_num + 1,
[138] Fix | Delete
'parent_id' => $form_id,
[139] Fix | Delete
'meta_key' => '_seq_num',
[140] Fix | Delete
'meta_value' => $last_seq_num + 1
[141] Fix | Delete
) );
[142] Fix | Delete
$wpdb->update( $wpdb->prefix . 'nf3_forms', array( 'seq_num' => $last_seq_num + 1 ), array( 'id' => $form_id ) );
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
return $last_seq_num;
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
public static function import( array $import, $id = '', $is_conversion )
[149] Fix | Delete
{
[150] Fix | Delete
$import = apply_filters( 'ninja_forms_before_import_form', $import );
[151] Fix | Delete
[152] Fix | Delete
/*
[153] Fix | Delete
* Create Form
[154] Fix | Delete
*/
[155] Fix | Delete
$form = Ninja_Forms()->form( $id )->get();
[156] Fix | Delete
$form->update_settings( $import[ 'settings' ] );
[157] Fix | Delete
[158] Fix | Delete
if( ! $is_conversion ) {
[159] Fix | Delete
$form->update_setting( 'created_at', current_time( 'mysql' ) );
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
$form->save();
[163] Fix | Delete
$form_id = $form->get_id();
[164] Fix | Delete
[165] Fix | Delete
$form_cache = array(
[166] Fix | Delete
'id' => $form_id,
[167] Fix | Delete
'fields' => array(),
[168] Fix | Delete
'actions' => array(),
[169] Fix | Delete
'settings' => $form->get_settings()
[170] Fix | Delete
);
[171] Fix | Delete
$update_process = Ninja_Forms()->background_process( 'update-fields' );
[172] Fix | Delete
foreach( $import[ 'fields' ] as $settings ){
[173] Fix | Delete
[174] Fix | Delete
if( $is_conversion ) {
[175] Fix | Delete
$field_id = $settings[ 'id' ];
[176] Fix | Delete
$field = Ninja_Forms()->form($form_id)->field( $field_id )->get();
[177] Fix | Delete
$field->save();
[178] Fix | Delete
} else {
[179] Fix | Delete
unset( $settings[ 'id' ] );
[180] Fix | Delete
$settings[ 'created_at' ] = current_time( 'mysql' );
[181] Fix | Delete
$field = Ninja_Forms()->form($form_id)->field()->get();
[182] Fix | Delete
/**
[183] Fix | Delete
* If this is the default contact form,
[184] Fix | Delete
* ensure that we properly save the fields
[185] Fix | Delete
* to avoid the loss of settings when the cache is disabled.
[186] Fix | Delete
*/
[187] Fix | Delete
if ( 1 == $form_id ) {
[188] Fix | Delete
$field->update_settings( $settings );
[189] Fix | Delete
}
[190] Fix | Delete
$field->save();
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
$settings[ 'parent_id' ] = $form_id;
[194] Fix | Delete
[195] Fix | Delete
array_push( $form_cache[ 'fields' ], array(
[196] Fix | Delete
'id' => $field->get_id(),
[197] Fix | Delete
'settings' => $settings
[198] Fix | Delete
));
[199] Fix | Delete
[200] Fix | Delete
$update_process->push_to_queue(array(
[201] Fix | Delete
'id' => $field->get_id(),
[202] Fix | Delete
'settings' => $settings
[203] Fix | Delete
));
[204] Fix | Delete
}
[205] Fix | Delete
$update_process->save()->dispatch();
[206] Fix | Delete
[207] Fix | Delete
foreach( $import[ 'actions' ] as $settings ){
[208] Fix | Delete
[209] Fix | Delete
$action = Ninja_Forms()->form($form_id)->action()->get();
[210] Fix | Delete
[211] Fix | Delete
if( ! $is_conversion ) {
[212] Fix | Delete
$settings[ 'created_at' ] = current_time( 'mysql' );
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
$action->update_settings( $settings )->save();
[216] Fix | Delete
[217] Fix | Delete
array_push( $form_cache[ 'actions' ], array(
[218] Fix | Delete
'id' => $action->get_id(),
[219] Fix | Delete
'settings' => $settings
[220] Fix | Delete
));
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
WPN_Helper::update_nf_cache( $form_id, $form_cache );
[224] Fix | Delete
[225] Fix | Delete
add_action( 'admin_notices', array( 'NF_Database_Models_Form', 'import_admin_notice' ) );
[226] Fix | Delete
[227] Fix | Delete
self::$imported_form_id = $form_id;
[228] Fix | Delete
[229] Fix | Delete
return $form_id;
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
public static function import_admin_notice()
[233] Fix | Delete
{
[234] Fix | Delete
Ninja_Forms()->template( 'admin-notice-form-import.html.php', array( 'form_id'=> self::$imported_form_id ) );
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
/**
[238] Fix | Delete
* This static method is called to duplicate a form using the form ID.
[239] Fix | Delete
*
[240] Fix | Delete
* To duplicate a form we:
[241] Fix | Delete
*
[242] Fix | Delete
* Check to see if we've ran stage one of the db update process.
[243] Fix | Delete
* Use SQL to insert a copy of our form and form meta.
[244] Fix | Delete
* Grab all fields for a specific form.
[245] Fix | Delete
* Loop over those fields and insert fields and field meta.
[246] Fix | Delete
* Run ->update_settings() and ->save() on the form model.
[247] Fix | Delete
* Call our WPN_Helper method to build a form cache.
[248] Fix | Delete
*
[249] Fix | Delete
* @since 3.0
[250] Fix | Delete
* @update 3.4.0
[251] Fix | Delete
* @param int $form_id ID of the form being duplicated.
[252] Fix | Delete
* @return $new_form_id ID of our form duplicate.
[253] Fix | Delete
*/
[254] Fix | Delete
public static function duplicate( $form_id )
[255] Fix | Delete
{
[256] Fix | Delete
global $wpdb;
[257] Fix | Delete
[258] Fix | Delete
[259] Fix | Delete
/**
[260] Fix | Delete
* Check to see if we've got new field columns.
[261] Fix | Delete
*
[262] Fix | Delete
* We do this here instead of the get_sql_queries() method so that we don't hit the db multiple times.
[263] Fix | Delete
*/
[264] Fix | Delete
$sql = "SHOW COLUMNS FROM {$wpdb->prefix}nf3_fields LIKE 'field_key'";
[265] Fix | Delete
$results = $wpdb->get_results( $sql );
[266] Fix | Delete
[267] Fix | Delete
// If we don't have the field_key column, we need to remove our new columns.
[268] Fix | Delete
if ( empty ( $results ) ) {
[269] Fix | Delete
$db_stage_one_complete = false;
[270] Fix | Delete
} else {
[271] Fix | Delete
$db_stage_one_complete = true;
[272] Fix | Delete
}
[273] Fix | Delete
[274] Fix | Delete
// Duplicate the Form Object.
[275] Fix | Delete
$wpdb->query( $wpdb->prepare(
[276] Fix | Delete
"
[277] Fix | Delete
INSERT INTO {$wpdb->prefix}nf3_forms ( `title` )
[278] Fix | Delete
SELECT CONCAT( `title`, ' - ', %s )
[279] Fix | Delete
FROM {$wpdb->prefix}nf3_forms
[280] Fix | Delete
WHERE id = %d;
[281] Fix | Delete
", esc_html__( 'copy', 'ninja-forms' ), $form_id
[282] Fix | Delete
) );
[283] Fix | Delete
$new_form_id = $wpdb->insert_id;
[284] Fix | Delete
[285] Fix | Delete
$blacklist = array(
[286] Fix | Delete
'_seq_num',
[287] Fix | Delete
'embed_form',
[288] Fix | Delete
'public_link',
[289] Fix | Delete
'public_link_key',
[290] Fix | Delete
'allow_public_link',
[291] Fix | Delete
);
[292] Fix | Delete
$blacklist = apply_filters( 'ninja_forms_excluded_duplicate_form_settings', $blacklist );
[293] Fix | Delete
$blacklist = "'" . implode( "','", $blacklist ) . "'";
[294] Fix | Delete
[295] Fix | Delete
// Duplicate the Form Meta.
[296] Fix | Delete
$wpdb->query( $wpdb->prepare(
[297] Fix | Delete
"
[298] Fix | Delete
INSERT INTO {$wpdb->prefix}nf3_form_meta ( `parent_id`, `key`, `value` )
[299] Fix | Delete
SELECT %d, `key`, `value`
[300] Fix | Delete
FROM {$wpdb->prefix}nf3_form_meta
[301] Fix | Delete
WHERE parent_id = %d
[302] Fix | Delete
AND `key` NOT IN({$blacklist});
[303] Fix | Delete
", $new_form_id, $form_id
[304] Fix | Delete
));
[305] Fix | Delete
[306] Fix | Delete
// Get the fields to duplicate
[307] Fix | Delete
$old_fields = $wpdb->get_results( $wpdb->prepare(
[308] Fix | Delete
"
[309] Fix | Delete
SELECT `id`
[310] Fix | Delete
FROM {$wpdb->prefix}nf3_fields
[311] Fix | Delete
WHERE parent_id = %d
[312] Fix | Delete
", $form_id
[313] Fix | Delete
));
[314] Fix | Delete
[315] Fix | Delete
// Get our field and field_meta table column names and values.
[316] Fix | Delete
$fields_sql = self::get_sql_queries( 'field_table_columns', $db_stage_one_complete );
[317] Fix | Delete
$field_meta_sql = self::get_sql_queries( 'field_meta_table_columns', $db_stage_one_complete );
[318] Fix | Delete
[319] Fix | Delete
foreach( $old_fields as $old_field ){
[320] Fix | Delete
[321] Fix | Delete
// Duplicate the Field Object.
[322] Fix | Delete
$wpdb->query( $wpdb->prepare(
[323] Fix | Delete
"
[324] Fix | Delete
INSERT INTO {$wpdb->prefix}nf3_fields ( {$fields_sql[ 'insert' ]} )
[325] Fix | Delete
SELECT {$fields_sql[ 'select' ]}
[326] Fix | Delete
FROM {$wpdb->prefix}nf3_fields
[327] Fix | Delete
WHERE id = %d
[328] Fix | Delete
", $new_form_id, $old_field->id
[329] Fix | Delete
));
[330] Fix | Delete
$new_field_id = $wpdb->insert_id;
[331] Fix | Delete
[332] Fix | Delete
// Duplicate the Field Meta.
[333] Fix | Delete
$wpdb->query( $wpdb->prepare(
[334] Fix | Delete
"
[335] Fix | Delete
INSERT INTO {$wpdb->prefix}nf3_field_meta ( {$field_meta_sql[ 'insert' ]} )
[336] Fix | Delete
SELECT {$field_meta_sql[ 'select' ]}
[337] Fix | Delete
FROM {$wpdb->prefix}nf3_field_meta
[338] Fix | Delete
WHERE parent_id = %d;
[339] Fix | Delete
", $new_field_id, $old_field->id
[340] Fix | Delete
));
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
// Duplicate the Actions.
[344] Fix | Delete
[345] Fix | Delete
// Get the actions to duplicate
[346] Fix | Delete
$old_actions = $wpdb->get_results( $wpdb->prepare(
[347] Fix | Delete
"
[348] Fix | Delete
SELECT `id`
[349] Fix | Delete
FROM {$wpdb->prefix}nf3_actions
[350] Fix | Delete
WHERE parent_id = %d
[351] Fix | Delete
", $form_id
[352] Fix | Delete
));
[353] Fix | Delete
[354] Fix | Delete
// Get our action and action_meta table columns and values.
[355] Fix | Delete
$actions_sql = self::get_sql_queries( 'action_table_columns', $db_stage_one_complete );
[356] Fix | Delete
$actions_meta_sql = self::get_sql_queries( 'action_meta_table_columns', $db_stage_one_complete );
[357] Fix | Delete
[358] Fix | Delete
foreach( $old_actions as $old_action ){
[359] Fix | Delete
// Duplicate the Action Object.
[360] Fix | Delete
$wpdb->query( $wpdb->prepare(
[361] Fix | Delete
"
[362] Fix | Delete
INSERT INTO {$wpdb->prefix}nf3_actions ( {$actions_sql[ 'insert' ]} )
[363] Fix | Delete
SELECT {$actions_sql[ 'select' ]}
[364] Fix | Delete
FROM {$wpdb->prefix}nf3_actions
[365] Fix | Delete
WHERE id = %d
[366] Fix | Delete
", $new_form_id, $old_action->id
[367] Fix | Delete
));
[368] Fix | Delete
$new_action_id = $wpdb->insert_id;
[369] Fix | Delete
// Duplicate the Action Meta.
[370] Fix | Delete
$wpdb->query( $wpdb->prepare(
[371] Fix | Delete
"
[372] Fix | Delete
INSERT INTO {$wpdb->prefix}nf3_action_meta ( {$actions_meta_sql[ 'insert' ]} )
[373] Fix | Delete
SELECT {$actions_meta_sql[ 'select' ]}
[374] Fix | Delete
FROM {$wpdb->prefix}nf3_action_meta
[375] Fix | Delete
WHERE parent_id = %d;
[376] Fix | Delete
", $new_action_id, $old_action->id
[377] Fix | Delete
));
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
/*
[381] Fix | Delete
* In order for our new form and form_meta fields to populate on
[382] Fix | Delete
* duplicate we need to update_settings and save
[383] Fix | Delete
*/
[384] Fix | Delete
$new_form = Ninja_Forms()->form( $new_form_id )->get();
[385] Fix | Delete
$new_form->update_settings( $new_form->get_settings() );
[386] Fix | Delete
$new_form->save();
[387] Fix | Delete
[388] Fix | Delete
/*
[389] Fix | Delete
* Build a cache for this new form.
[390] Fix | Delete
*/
[391] Fix | Delete
WPN_Helper::build_nf_cache( $new_form_id );
[392] Fix | Delete
[393] Fix | Delete
return $new_form_id;
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
/**
[397] Fix | Delete
* When duplicating a form, we need to build specific SQL queries.
[398] Fix | Delete
*
[399] Fix | Delete
* This is a fairly repetative task, so we've extrapolated the code to its own function.
[400] Fix | Delete
*
[401] Fix | Delete
* @since 3.4.0
[402] Fix | Delete
* @param string $table_name Name of the table we want to update.
[403] Fix | Delete
* @return array Associative array like: ['insert' => "`column1`, "`column2`", etc", 'select' => "`column1`, etc."]
[404] Fix | Delete
*/
[405] Fix | Delete
private static function get_sql_queries( $table_name, $db_stage_one_complete = true )
[406] Fix | Delete
{
[407] Fix | Delete
/**
[408] Fix | Delete
* These arrays contain the columns in our database.
[409] Fix | Delete
*
[410] Fix | Delete
* Later, if the user hasn't ran stage one of our db update process, we'll remove the items that aren't supported.
[411] Fix | Delete
*/
[412] Fix | Delete
$db_columns = array(
[413] Fix | Delete
'field_table_columns' => array(
[414] Fix | Delete
'label',
[415] Fix | Delete
'key',
[416] Fix | Delete
'type',
[417] Fix | Delete
'parent_id',
[418] Fix | Delete
'field_label',
[419] Fix | Delete
'field_key',
[420] Fix | Delete
'order',
[421] Fix | Delete
'required',
[422] Fix | Delete
'default_value',
[423] Fix | Delete
'label_pos',
[424] Fix | Delete
'personally_identifiable',
[425] Fix | Delete
),
[426] Fix | Delete
[427] Fix | Delete
'field_meta_table_columns' => array(
[428] Fix | Delete
'parent_id',
[429] Fix | Delete
'key',
[430] Fix | Delete
'value',
[431] Fix | Delete
'meta_key',
[432] Fix | Delete
'meta_value',
[433] Fix | Delete
),
[434] Fix | Delete
[435] Fix | Delete
'action_table_columns' => array(
[436] Fix | Delete
'title',
[437] Fix | Delete
'key',
[438] Fix | Delete
'type',
[439] Fix | Delete
'active',
[440] Fix | Delete
'parent_id',
[441] Fix | Delete
'label',
[442] Fix | Delete
),
[443] Fix | Delete
[444] Fix | Delete
'action_meta_table_columns' => array(
[445] Fix | Delete
'parent_id',
[446] Fix | Delete
'key',
[447] Fix | Delete
'value',
[448] Fix | Delete
'meta_key',
[449] Fix | Delete
'meta_value',
[450] Fix | Delete
),
[451] Fix | Delete
);
[452] Fix | Delete
[453] Fix | Delete
// If we haven't been passed a table name or the table name is invalid, return false.
[454] Fix | Delete
if ( empty( $table_name ) || ! isset( $db_columns[ $table_name ] ) ) {return false;}
[455] Fix | Delete
[456] Fix | Delete
// If we have not completed stage one of our db update, then we unset new db columns.
[457] Fix | Delete
if ( ! $db_stage_one_complete ) {
[458] Fix | Delete
[459] Fix | Delete
$db_columns[ 'field_table_columns' ] = array_diff(
[460] Fix | Delete
$db_columns[ 'field_table_columns' ],
[461] Fix | Delete
array(
[462] Fix | Delete
'field_label',
[463] Fix | Delete
'field_key',
[464] Fix | Delete
'order',
[465] Fix | Delete
'required',
[466] Fix | Delete
'default_value',
[467] Fix | Delete
'label_pos',
[468] Fix | Delete
'personally_identifiable'
[469] Fix | Delete
)
[470] Fix | Delete
);
[471] Fix | Delete
[472] Fix | Delete
$db_columns[ 'field_meta_table_columns' ] = array_diff(
[473] Fix | Delete
$db_columns[ 'field_meta_table_columns'],
[474] Fix | Delete
array(
[475] Fix | Delete
'meta_key',
[476] Fix | Delete
'meta_value'
[477] Fix | Delete
)
[478] Fix | Delete
);
[479] Fix | Delete
[480] Fix | Delete
$db_columns[ 'action_table_columns' ] = array_diff(
[481] Fix | Delete
$db_columns[ 'action_table_columns' ],
[482] Fix | Delete
array(
[483] Fix | Delete
'label'
[484] Fix | Delete
)
[485] Fix | Delete
);
[486] Fix | Delete
[487] Fix | Delete
$db_columns[ 'action_meta_table_columns' ] = array_diff(
[488] Fix | Delete
$db_columns[ 'action_meta_table_columns' ],
[489] Fix | Delete
array(
[490] Fix | Delete
'meta_key',
[491] Fix | Delete
'meta_value'
[492] Fix | Delete
)
[493] Fix | Delete
);
[494] Fix | Delete
}
[495] Fix | Delete
[496] Fix | Delete
/**
[497] Fix | Delete
* $sql_insert is a var that tracks which table columns we want to insert.
[498] Fix | Delete
*/
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function