ninja_forms_insert_fav

The Ninja Forms ninja forms insert fav function.

Description

ninja_forms_insert_fav(); 

Usage

  1. if ( !function_exists( 'ninja_forms_insert_fav' ) ) { 
  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_fav(); 
  7.  

Defined (1)

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

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