Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../deprecat.../includes/admin
File: ajax.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
add_action( 'wp_ajax_ninja_forms_save_metabox_state', 'ninja_forms_save_metabox_state' );
[2] Fix | Delete
function ninja_forms_save_metabox_state(){
[3] Fix | Delete
// Bail if we aren't in the admin
[4] Fix | Delete
if ( ! is_admin() )
[5] Fix | Delete
return false;
[6] Fix | Delete
[7] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[8] Fix | Delete
[9] Fix | Delete
$plugin_settings = nf_get_settings();
[10] Fix | Delete
$page = esc_html( $_REQUEST['page'] );
[11] Fix | Delete
$tab = esc_html( $_REQUEST['tab'] );
[12] Fix | Delete
$slug = esc_html( $_REQUEST['slug'] );
[13] Fix | Delete
$metabox_state = esc_html( $_REQUEST['metabox_state'] );
[14] Fix | Delete
$plugin_settings['metabox_state'][$page][$tab][$slug] = $metabox_state;
[15] Fix | Delete
update_option( 'ninja_forms_settings', $plugin_settings );
[16] Fix | Delete
[17] Fix | Delete
die();
[18] Fix | Delete
}
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* When a field settings metabox is expanded, return a JSON element containing the field settings HTML
[22] Fix | Delete
*
[23] Fix | Delete
* @since 2.9
[24] Fix | Delete
* @return false;
[25] Fix | Delete
*/
[26] Fix | Delete
[27] Fix | Delete
function nf_output_field_settings_html() {
[28] Fix | Delete
global $nf_rte_editors;
[29] Fix | Delete
[30] Fix | Delete
// Bail if we aren't in the admin
[31] Fix | Delete
if ( ! is_admin() )
[32] Fix | Delete
return false;
[33] Fix | Delete
[34] Fix | Delete
// Bail if we don't have proper permissions
[35] Fix | Delete
if ( ! current_user_can( apply_filters( 'nf_new_field_capabilities', 'manage_options' ) ) )
[36] Fix | Delete
return false;
[37] Fix | Delete
[38] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[39] Fix | Delete
[40] Fix | Delete
$field_id = esc_html( $_REQUEST['field_id'] );
[41] Fix | Delete
$data = isset ( $_REQUEST['data'] ) ? json_decode( stripslashes( $_REQUEST['data'] ), true ) : array();
[42] Fix | Delete
[43] Fix | Delete
$field = ninja_forms_get_field_by_id( $field_id );
[44] Fix | Delete
$field_data = $field['data'];
[45] Fix | Delete
$data = wp_parse_args( $data, $field_data );
[46] Fix | Delete
[47] Fix | Delete
nf_output_registered_field_settings( $field_id, $data );
[48] Fix | Delete
[49] Fix | Delete
die();
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
add_action( 'wp_ajax_nf_output_field_settings_html', 'nf_output_field_settings_html' );
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Save our admin fields page.
[56] Fix | Delete
*
[57] Fix | Delete
* @since 2.9
[58] Fix | Delete
* @return false;
[59] Fix | Delete
*/
[60] Fix | Delete
[61] Fix | Delete
function nf_admin_save_builder() {
[62] Fix | Delete
global $ninja_forms_fields, $wpdb;
[63] Fix | Delete
[64] Fix | Delete
// Bail if we aren't in the admin
[65] Fix | Delete
if ( ! is_admin() )
[66] Fix | Delete
return false;
[67] Fix | Delete
[68] Fix | Delete
// Bail if we don't have proper permissions
[69] Fix | Delete
if ( ! current_user_can( apply_filters( 'nf_new_field_capabilities', 'manage_options' ) ) )
[70] Fix | Delete
return false;
[71] Fix | Delete
[72] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[73] Fix | Delete
[74] Fix | Delete
$field_data = json_decode( stripslashes( $_REQUEST['field_data'] ), true );
[75] Fix | Delete
$form_id = esc_html( $_REQUEST['form_id'] );
[76] Fix | Delete
$form_title = stripslashes( $_REQUEST['form_title'] );
[77] Fix | Delete
$field_order = json_decode( strip_tags( stripslashes( $_REQUEST['field_order'] ) ), true );
[78] Fix | Delete
[79] Fix | Delete
if ( is_array ( $field_order ) ) {
[80] Fix | Delete
$order_array = array();
[81] Fix | Delete
$x = 0;
[82] Fix | Delete
foreach ( $field_order as $id ) {
[83] Fix | Delete
$id = str_replace( 'ninja_forms_field_', '', $id );
[84] Fix | Delete
$order_array[ $id ] = $x;
[85] Fix | Delete
$x++;
[86] Fix | Delete
}
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$tmp_array = array();
[90] Fix | Delete
foreach ( $field_data as $field ) {
[91] Fix | Delete
$field_id = $field['id'];
[92] Fix | Delete
unset( $field['id'] );
[93] Fix | Delete
unset( $field['metabox_state'] );
[94] Fix | Delete
$tmp_array[ $field_id ] = $field;
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
$field_data = $tmp_array;
[98] Fix | Delete
[99] Fix | Delete
if ( isset ( $ninja_forms_fields ) && is_array( $ninja_forms_fields ) ) {
[100] Fix | Delete
foreach ( $ninja_forms_fields as $slug => $field ){
[101] Fix | Delete
if ( $field['save_function'] != '') {
[102] Fix | Delete
$save_function = $field['save_function'];
[103] Fix | Delete
$arguments['form_id'] = $form_id;
[104] Fix | Delete
$arguments['data'] = $field_data;
[105] Fix | Delete
$field_data = call_user_func_array( $save_function, $arguments );
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
if( $form_id != '' && $form_id != 0 && $form_id != 'new' ){
[111] Fix | Delete
foreach ( $field_data as $field_id => $vals ) {
[112] Fix | Delete
$field_order = isset( $order_array[$field_id] ) ? $order_array[$field_id] : '';
[113] Fix | Delete
$field_row = ninja_forms_get_field_by_id( $field_id );
[114] Fix | Delete
$data = $field_row['data'];
[115] Fix | Delete
foreach( $vals as $k => $v ){
[116] Fix | Delete
$data[$k] = $v;
[117] Fix | Delete
}
[118] Fix | Delete
$data_array = array('data' => serialize( $data ), 'order' => $field_order);
[119] Fix | Delete
$wpdb->update( NINJA_FORMS_FIELDS_TABLE_NAME, $data_array, array( 'id' => $field_id ));
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
$date_updated = date( 'Y-m-d H:i:s', strtotime ( 'now' ) );
[123] Fix | Delete
Ninja_Forms()->form( $form_id )->update_setting( 'form_title', $form_title );
[124] Fix | Delete
Ninja_Forms()->form( $form_id )->update_setting( 'date_updated', $date_updated );
[125] Fix | Delete
Ninja_Forms()->form( $form_id )->update_setting( 'status', '' );
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
// Dump our current form transient.
[129] Fix | Delete
delete_transient( 'nf_form_' . $form_id );
[130] Fix | Delete
[131] Fix | Delete
die();
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
add_action( 'wp_ajax_nf_admin_save_builder', 'nf_admin_save_builder' );
[135] Fix | Delete
[136] Fix | Delete
[137] Fix | Delete
add_action('wp_ajax_ninja_forms_new_field', 'ninja_forms_new_field');
[138] Fix | Delete
function ninja_forms_new_field(){
[139] Fix | Delete
global $wpdb, $ninja_forms_fields;
[140] Fix | Delete
[141] Fix | Delete
// Bail if we aren't in the admin
[142] Fix | Delete
if ( ! is_admin() )
[143] Fix | Delete
return false;
[144] Fix | Delete
[145] Fix | Delete
// Bail if we don't have proper permissions
[146] Fix | Delete
if ( ! current_user_can( apply_filters( 'nf_new_field_capabilities', 'manage_options' ) ) )
[147] Fix | Delete
return false;
[148] Fix | Delete
[149] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[150] Fix | Delete
[151] Fix | Delete
$type = esc_html( $_REQUEST['type'] );
[152] Fix | Delete
$form_id = absint( $_REQUEST['form_id'] );
[153] Fix | Delete
[154] Fix | Delete
if( isset( $ninja_forms_fields[$type]['name'] ) ){
[155] Fix | Delete
$type_name = $ninja_forms_fields[$type]['name'];
[156] Fix | Delete
}else{
[157] Fix | Delete
$type_name = '';
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
if( isset( $ninja_forms_fields[$type]['default_label'] ) ){
[161] Fix | Delete
$default_label = $ninja_forms_fields[$type]['default_label'];
[162] Fix | Delete
}else{
[163] Fix | Delete
$default_label = '';
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
if( isset( $ninja_forms_fields[$type]['edit_options'] ) ){
[167] Fix | Delete
$edit_options = $ninja_forms_fields[$type]['edit_options'];
[168] Fix | Delete
}else{
[169] Fix | Delete
$edit_options = '';
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
if ( $default_label != '' ) {
[173] Fix | Delete
$label = $default_label;
[174] Fix | Delete
} else {
[175] Fix | Delete
$label = $type_name;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
$input_limit_msg = __( 'character(s) left', 'ninja-forms' );
[179] Fix | Delete
[180] Fix | Delete
$data = serialize( array( 'label' => $label, 'input_limit_msg' => $input_limit_msg ) );
[181] Fix | Delete
[182] Fix | Delete
$order = 999;
[183] Fix | Delete
[184] Fix | Delete
if($form_id != 0 && $form_id != ''){
[185] Fix | Delete
$args = array(
[186] Fix | Delete
'type' => $type,
[187] Fix | Delete
'data' => $data,
[188] Fix | Delete
);
[189] Fix | Delete
[190] Fix | Delete
$new_id = ninja_forms_insert_field( $form_id, $args );
[191] Fix | Delete
$new_html = ninja_forms_return_echo('ninja_forms_edit_field', $new_id, true );
[192] Fix | Delete
header("Content-type: application/json");
[193] Fix | Delete
$array = array ('new_id' => $new_id, 'new_type' => $type_name, 'new_html' => $new_html, 'edit_options' => $edit_options, 'new_type_slug' => $type );
[194] Fix | Delete
echo json_encode($array);
[195] Fix | Delete
die();
[196] Fix | Delete
}
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
add_action('wp_ajax_ninja_forms_remove_field', 'ninja_forms_remove_field');
[200] Fix | Delete
function ninja_forms_remove_field(){
[201] Fix | Delete
global $wpdb;
[202] Fix | Delete
[203] Fix | Delete
// Bail if we aren't in the admin
[204] Fix | Delete
if ( ! is_admin() )
[205] Fix | Delete
return false;
[206] Fix | Delete
[207] Fix | Delete
// Bail if we don't have proper permissions
[208] Fix | Delete
if ( ! current_user_can( apply_filters( 'nf_delete_field_capabilities', 'manage_options' ) ) )
[209] Fix | Delete
return false;
[210] Fix | Delete
[211] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[212] Fix | Delete
[213] Fix | Delete
$field_id = absint( $_REQUEST['field_id'] );
[214] Fix | Delete
$form_id = absint( $_REQUEST['form_id'] );
[215] Fix | Delete
$wpdb->query($wpdb->prepare("DELETE FROM ".NINJA_FORMS_FIELDS_TABLE_NAME." WHERE id = %d", $field_id));
[216] Fix | Delete
Ninja_Forms()->form( $form_id )->dump_cache();
[217] Fix | Delete
die();
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
add_action('wp_ajax_ninja_forms_add_list_option', 'ninja_forms_add_list_options');
[221] Fix | Delete
function ninja_forms_add_list_options(){
[222] Fix | Delete
global $wpdb;
[223] Fix | Delete
[224] Fix | Delete
// Bail if we aren't in the admin
[225] Fix | Delete
if ( ! is_admin() )
[226] Fix | Delete
return false;
[227] Fix | Delete
[228] Fix | Delete
// Bail if we don't have proper permissions
[229] Fix | Delete
if ( ! current_user_can( apply_filters( 'nf_new_field_capabilities', 'manage_options' ) ) )
[230] Fix | Delete
return false;
[231] Fix | Delete
[232] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[233] Fix | Delete
[234] Fix | Delete
$field_id = absint( $_REQUEST['field_id'] );
[235] Fix | Delete
$x = absint( $_REQUEST['x'] );
[236] Fix | Delete
$hidden_value = esc_html( $_REQUEST['hidden_value'] );
[237] Fix | Delete
ninja_forms_field_list_option_output($field_id, $x, '', $hidden_value);
[238] Fix | Delete
die();
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
function ninja_forms_insert_fav(){
[242] Fix | Delete
global $wpdb, $ninja_forms_fields;
[243] Fix | Delete
// Bail if we aren't in the admin
[244] Fix | Delete
if ( ! is_admin() )
[245] Fix | Delete
return false;
[246] Fix | Delete
[247] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[248] Fix | Delete
[249] Fix | Delete
$fav_id = absint( $_REQUEST['field_id'] );
[250] Fix | Delete
$form_id = absint( $_REQUEST['form_id'] );
[251] Fix | Delete
[252] Fix | Delete
$fav_row = ninja_forms_get_fav_by_id($fav_id);
[253] Fix | Delete
[254] Fix | Delete
$data = serialize($fav_row['data']);
[255] Fix | Delete
$type = $fav_row['type'];
[256] Fix | Delete
$type_name = $ninja_forms_fields[$type]['name'];
[257] Fix | Delete
[258] Fix | Delete
if($form_id != 0 && $form_id != ''){
[259] Fix | Delete
$args = array(
[260] Fix | Delete
'type' => $type,
[261] Fix | Delete
'data' => $data,
[262] Fix | Delete
'fav_id' => $fav_id,
[263] Fix | Delete
);
[264] Fix | Delete
$new_id = ninja_forms_insert_field( $form_id, $args );
[265] Fix | Delete
$new_html = ninja_forms_return_echo('ninja_forms_edit_field', $new_id, true );
[266] Fix | Delete
header("Content-type: application/json");
[267] Fix | Delete
$array = array ('new_id' => $new_id, 'new_type' => $type_name, 'new_html' => $new_html);
[268] Fix | Delete
echo json_encode($array);
[269] Fix | Delete
}
[270] Fix | Delete
die();
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
[274] Fix | Delete
add_action('wp_ajax_ninja_forms_insert_fav', 'ninja_forms_insert_fav');
[275] Fix | Delete
[276] Fix | Delete
function ninja_forms_insert_def(){
[277] Fix | Delete
global $wpdb, $ninja_forms_fields;
[278] Fix | Delete
[279] Fix | Delete
// Bail if we aren't in the admin
[280] Fix | Delete
if ( ! is_admin() )
[281] Fix | Delete
return false;
[282] Fix | Delete
[283] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[284] Fix | Delete
[285] Fix | Delete
$def_id = absint( $_REQUEST['field_id'] );
[286] Fix | Delete
$form_id = absint( $_REQUEST['form_id'] );
[287] Fix | Delete
[288] Fix | Delete
$def_row = ninja_forms_get_def_by_id($def_id);
[289] Fix | Delete
[290] Fix | Delete
$data = serialize($def_row['data']);
[291] Fix | Delete
$type = $def_row['type'];
[292] Fix | Delete
$type_name = $ninja_forms_fields[$type]['name'];
[293] Fix | Delete
[294] Fix | Delete
if($form_id != 0 && $form_id != ''){
[295] Fix | Delete
$args = array(
[296] Fix | Delete
'type' => $type,
[297] Fix | Delete
'data' => $data,
[298] Fix | Delete
'def_id' => $def_id,
[299] Fix | Delete
);
[300] Fix | Delete
$new_id = ninja_forms_insert_field( $form_id, $args );
[301] Fix | Delete
$new_html = ninja_forms_return_echo('ninja_forms_edit_field', $new_id, true );
[302] Fix | Delete
header("Content-type: application/json");
[303] Fix | Delete
$array = array ('new_id' => $new_id, 'new_type' => $type_name, 'new_html' => $new_html);
[304] Fix | Delete
echo json_encode($array);
[305] Fix | Delete
}
[306] Fix | Delete
die();
[307] Fix | Delete
}
[308] Fix | Delete
[309] Fix | Delete
add_action('wp_ajax_ninja_forms_insert_def', 'ninja_forms_insert_def');
[310] Fix | Delete
[311] Fix | Delete
add_action('wp_ajax_ninja_forms_add_fav', 'ninja_forms_add_fav');
[312] Fix | Delete
function ninja_forms_add_fav(){
[313] Fix | Delete
global $wpdb;
[314] Fix | Delete
[315] Fix | Delete
// Bail if we aren't in the admin
[316] Fix | Delete
if ( ! is_admin() )
[317] Fix | Delete
return false;
[318] Fix | Delete
[319] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[320] Fix | Delete
[321] Fix | Delete
$field_data = $_REQUEST['field_data'];
[322] Fix | Delete
$field_id = absint( $_REQUEST['field_id'] );
[323] Fix | Delete
[324] Fix | Delete
$field_row = ninja_forms_get_field_by_id($field_id);
[325] Fix | Delete
[326] Fix | Delete
$field_type = $field_row['type'];
[327] Fix | Delete
$form_id = 1;
[328] Fix | Delete
[329] Fix | Delete
$data = array();
[330] Fix | Delete
[331] Fix | Delete
foreach($field_data as $key => $val){
[332] Fix | Delete
$key = stripslashes( $key );
[333] Fix | Delete
$key = str_replace('"', '', $key);
[334] Fix | Delete
if(strpos($key, '[')){
[335] Fix | Delete
$key = str_replace(']', '', $key);
[336] Fix | Delete
$key = explode('[', $key);
[337] Fix | Delete
$multi = array();
[338] Fix | Delete
$temp =& $multi;
[339] Fix | Delete
$x = 0;
[340] Fix | Delete
$count = count($key) - 1;
[341] Fix | Delete
foreach ($key as $item){
[342] Fix | Delete
$temp[$item] = array();
[343] Fix | Delete
if($x < $count){
[344] Fix | Delete
$temp =& $temp[$item];
[345] Fix | Delete
}else{
[346] Fix | Delete
$temp[$item] = $val;
[347] Fix | Delete
}
[348] Fix | Delete
$x++;
[349] Fix | Delete
}
[350] Fix | Delete
$data = ninja_forms_array_merge_recursive($data, $multi);
[351] Fix | Delete
}else{
[352] Fix | Delete
$data[$key] = $val;
[353] Fix | Delete
}
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
$name = stripslashes( esc_html( $_REQUEST['fav_name'] ) );
[357] Fix | Delete
if ( !isset ( $data['label'] ) or empty ( $data['label'] ) ) {
[358] Fix | Delete
$data['label'] = $name;
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
$data = ninja_forms_stripslashes_deep( $data );
[362] Fix | Delete
[363] Fix | Delete
$data = serialize($data);
[364] Fix | Delete
$wpdb->insert(NINJA_FORMS_FAV_FIELDS_TABLE_NAME, array('row_type' => 1, 'type' => $field_type, 'order' => 0, 'data' => $data, 'name' => $name));
[365] Fix | Delete
$fav_id = $wpdb->insert_id;
[366] Fix | Delete
$update_array = array('fav_id' => $fav_id);
[367] Fix | Delete
$wpdb->update( NINJA_FORMS_FIELDS_TABLE_NAME, $update_array, array( 'id' => $field_id ));
[368] Fix | Delete
[369] Fix | Delete
$new_html = '<p class="button-controls" id="ninja_forms_insert_fav_field_'.$fav_id.'_p">
[370] Fix | Delete
<a class="button add-new-h2 ninja-forms-insert-fav-field" id="ninja_forms_insert_fav_field_'.$fav_id.'" data-field="' . $fav_id . '" data-type="fav" href="#">'.__($name, 'ninja-forms').'</a>
[371] Fix | Delete
</p>';
[372] Fix | Delete
[373] Fix | Delete
header("Content-type: application/json");
[374] Fix | Delete
$array = array ('fav_id' => $fav_id, 'fav_name' => $name, 'link_html' => $new_html);
[375] Fix | Delete
echo json_encode($array);
[376] Fix | Delete
[377] Fix | Delete
die();
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
add_action('wp_ajax_ninja_forms_add_def', 'ninja_forms_add_def');
[381] Fix | Delete
function ninja_forms_add_def(){
[382] Fix | Delete
global $wpdb;
[383] Fix | Delete
[384] Fix | Delete
// Bail if we aren't in the admin
[385] Fix | Delete
if ( ! is_admin() )
[386] Fix | Delete
return false;
[387] Fix | Delete
[388] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[389] Fix | Delete
[390] Fix | Delete
$field_data = $_REQUEST['field_data'];
[391] Fix | Delete
$field_id = absint( $_REQUEST['field_id'] );
[392] Fix | Delete
[393] Fix | Delete
$field_row = ninja_forms_get_field_by_id($field_id);
[394] Fix | Delete
[395] Fix | Delete
$field_type = $field_row['type'];
[396] Fix | Delete
$row_type = 0;
[397] Fix | Delete
[398] Fix | Delete
$data = array();
[399] Fix | Delete
[400] Fix | Delete
foreach($field_data as $key => $val){
[401] Fix | Delete
$key = str_replace('"', '', $key);
[402] Fix | Delete
if(strpos($key, '[')){
[403] Fix | Delete
$key = str_replace(']', '', $key);
[404] Fix | Delete
$key = explode('[', $key);
[405] Fix | Delete
$multi = array();
[406] Fix | Delete
$temp =& $multi;
[407] Fix | Delete
$x = 0;
[408] Fix | Delete
$count = count($key) - 1;
[409] Fix | Delete
foreach ($key as $item){
[410] Fix | Delete
$temp[$item] = array();
[411] Fix | Delete
if($x < $count){
[412] Fix | Delete
$temp =& $temp[$item];
[413] Fix | Delete
}else{
[414] Fix | Delete
$temp[$item] = $val;
[415] Fix | Delete
}
[416] Fix | Delete
$x++;
[417] Fix | Delete
}
[418] Fix | Delete
$data = ninja_forms_array_merge_recursive($data, $multi);
[419] Fix | Delete
}else{
[420] Fix | Delete
$data[$key] = $val;
[421] Fix | Delete
}
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
$name = stripslashes( esc_html( $_REQUEST['def_name'] ) );
[425] Fix | Delete
$data['label'] = $name;
[426] Fix | Delete
$data = serialize($data);
[427] Fix | Delete
$wpdb->insert(NINJA_FORMS_FAV_FIELDS_TABLE_NAME, array('row_type' => $row_type, 'type' => $field_type, 'data' => $data, 'name' => $name));
[428] Fix | Delete
$def_id = $wpdb->insert_id;
[429] Fix | Delete
$update_array = array('def_id' => $def_id);
[430] Fix | Delete
$wpdb->update( NINJA_FORMS_FIELDS_TABLE_NAME, $update_array, array( 'id' => $field_id ));
[431] Fix | Delete
[432] Fix | Delete
$new_html = '<p class="button-controls" id="ninja_forms_insert_def_field_'.$def_id.'_p">
[433] Fix | Delete
<a class="button add-new-h2 ninja-forms-insert-def-field" id="ninja_forms_insert_def_field_'.$def_id.'" name="" href="#">'.__($name, 'ninja-forms').'</a>
[434] Fix | Delete
</p>';
[435] Fix | Delete
header("Content-type: application/json");
[436] Fix | Delete
$array = array ('def_id' => $def_id, 'def_name' => $name, 'link_html' => $new_html);
[437] Fix | Delete
echo json_encode($array);
[438] Fix | Delete
[439] Fix | Delete
die();
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
add_action('wp_ajax_ninja_forms_remove_fav', 'ninja_forms_remove_fav');
[443] Fix | Delete
function ninja_forms_remove_fav(){
[444] Fix | Delete
global $wpdb, $ninja_forms_fields;
[445] Fix | Delete
[446] Fix | Delete
// Bail if we aren't in the admin
[447] Fix | Delete
if ( ! is_admin() )
[448] Fix | Delete
return false;
[449] Fix | Delete
[450] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[451] Fix | Delete
[452] Fix | Delete
$field_id = absint( $_REQUEST['field_id'] );
[453] Fix | Delete
$field_row = ninja_forms_get_field_by_id($field_id);
[454] Fix | Delete
$field_type = $field_row['type'];
[455] Fix | Delete
$fav_id = $field_row['fav_id'];
[456] Fix | Delete
$wpdb->query($wpdb->prepare("DELETE FROM ".NINJA_FORMS_FAV_FIELDS_TABLE_NAME." WHERE id = %d", $fav_id));
[457] Fix | Delete
$wpdb->update(NINJA_FORMS_FIELDS_TABLE_NAME, array('fav_id' => '' ), array('fav_id' => $fav_id));
[458] Fix | Delete
$type_name = $ninja_forms_fields[$field_type]['name'];
[459] Fix | Delete
header("Content-type: application/json");
[460] Fix | Delete
$array = array ('fav_id' => $fav_id, 'type_name' => $type_name);
[461] Fix | Delete
echo json_encode($array);
[462] Fix | Delete
[463] Fix | Delete
die();
[464] Fix | Delete
}
[465] Fix | Delete
[466] Fix | Delete
add_action('wp_ajax_ninja_forms_remove_def', 'ninja_forms_remove_def');
[467] Fix | Delete
function ninja_forms_remove_def(){
[468] Fix | Delete
global $wpdb, $ninja_forms_fields;
[469] Fix | Delete
[470] Fix | Delete
// Bail if we aren't in the admin
[471] Fix | Delete
if ( ! is_admin() )
[472] Fix | Delete
return false;
[473] Fix | Delete
[474] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[475] Fix | Delete
[476] Fix | Delete
$field_id = absint( $_REQUEST['field_id'] );
[477] Fix | Delete
$field_row = ninja_forms_get_field_by_id($field_id);
[478] Fix | Delete
$field_type = $field_row['type'];
[479] Fix | Delete
$def_id = $field_row['def_id'];
[480] Fix | Delete
$wpdb->query($wpdb->prepare("DELETE FROM ".NINJA_FORMS_FAV_FIELDS_TABLE_NAME." WHERE id = %d", $def_id));
[481] Fix | Delete
$wpdb->update(NINJA_FORMS_FIELDS_TABLE_NAME, array('def_id' => '' ), array('def_id' => $def_id));
[482] Fix | Delete
$type_name = $ninja_forms_fields[$field_type]['name'];
[483] Fix | Delete
header("Content-type: application/json");
[484] Fix | Delete
$array = array ('def_id' => $def_id, 'type_name' => $type_name);
[485] Fix | Delete
echo json_encode($array);
[486] Fix | Delete
[487] Fix | Delete
die();
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
add_action( 'wp_ajax_ninja_forms_side_sortable', 'ninja_forms_side_sortable' );
[491] Fix | Delete
function ninja_forms_side_sortable(){
[492] Fix | Delete
[493] Fix | Delete
// Bail if we aren't in the admin
[494] Fix | Delete
if ( ! is_admin() )
[495] Fix | Delete
return false;
[496] Fix | Delete
[497] Fix | Delete
check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' );
[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