ninja_forms_insert_def

The Ninja Forms ninja forms insert def function.

Description

ninja_forms_insert_def(); 

Usage

  1. if ( !function_exists( 'ninja_forms_insert_def' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/ajax.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = ninja_forms_insert_def(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/admin/ajax.php  
  1. function ninja_forms_insert_def() { 
  2. global $wpdb, $ninja_forms_fields; 
  3.  
  4. // Bail if we aren't in the admin 
  5. if ( ! is_admin() ) 
  6. return false; 
  7.  
  8. check_ajax_referer( 'nf_ajax', 'nf_ajax_nonce' ); 
  9.  
  10. $def_id = absint( $_REQUEST['field_id'] ); 
  11. $form_id = absint( $_REQUEST['form_id'] ); 
  12.  
  13. $def_row = ninja_forms_get_def_by_id($def_id); 
  14.  
  15. $data = serialize($def_row['data']); 
  16. $type = $def_row['type']; 
  17. $type_name = $ninja_forms_fields[$type]['name']; 
  18.  
  19. if($form_id != 0 && $form_id != '') { 
  20. $args = array( 
  21. 'type' => $type,  
  22. 'data' => $data,  
  23. 'def_id' => $def_id,  
  24. ); 
  25. $new_id = ninja_forms_insert_field( $form_id, $args ); 
  26. $new_html = ninja_forms_return_echo('ninja_forms_edit_field', $new_id, true ); 
  27. header("Content-type: application/json"); 
  28. $array = array ('new_id' => $new_id, 'new_type' => $type_name, 'new_html' => $new_html); 
  29. echo json_encode($array); 
  30. die();