ninja_forms_admin_save

The Ninja Forms ninja forms admin save function.

Description

ninja_forms_admin_save(); 

Usage

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

Defined (1)

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

/deprecated/includes/admin/save.php  
  1. function ninja_forms_admin_save() { 
  2. global $ninja_forms_tabs, $ninja_forms_sidebars, $ninja_forms_tabs_metaboxes, $ninja_forms_admin_update_message; 
  3. if(!empty($_POST) AND !empty($_POST['_ninja_forms_admin_submit']) AND $_POST['_ninja_forms_admin_submit'] != '') { 
  4. if(wp_verify_nonce($_POST['_ninja_forms_admin_submit'], '_ninja_forms_save') AND check_admin_referer('_ninja_forms_save', '_ninja_forms_admin_submit')) { 
  5. $current_page = esc_html( $_REQUEST['page'] ); 
  6. $current_tab = ninja_forms_get_current_tab(); 
  7.  
  8. $data_array = array(); 
  9. if ( isset( $_REQUEST['form_id'] ) and $_REQUEST['form_id'] != 'new' ) { 
  10. $form_id = absint( $_REQUEST['form_id'] ); 
  11.  
  12. // Dump our current form transient. 
  13. delete_transient( 'nf_form_' . $form_id ); 
  14. } else if ( isset ( $_REQUEST['form_id'] ) and $_REQUEST['form_id'] == 'new' ) { 
  15. $form_id = 'new'; 
  16. } else { 
  17. $form_id = ''; 
  18.  
  19. foreach ( $_POST as $key => $val ) { 
  20. if ( substr($key, 0, 1) != '_') { 
  21. $data_array[$key] = $val; 
  22.  
  23. $data_array = ninja_forms_stripslashes_deep( $data_array ); 
  24. //$data_array = ninja_forms_esc_html_deep( $data_array ); 
  25.  
  26. //Call any save functions registered to metaboxes 
  27. if( isset( $ninja_forms_tabs_metaboxes[$current_page][$current_tab] ) AND is_array( $ninja_forms_tabs_metaboxes[$current_page][$current_tab] ) AND !empty( $ninja_forms_tabs_metaboxes[$current_page][$current_tab] ) ) { 
  28. foreach( $ninja_forms_tabs_metaboxes[$current_page][$current_tab] as $slug => $opts ) { 
  29.  
  30. // Get the save function of our options, if set, and call them, passing the data that has been posted. 
  31. if( isset( $opts['settings'] ) AND !empty( $opts['settings'] ) ) { 
  32. foreach( $opts['settings'] as $setting ) { 
  33. if( isset( $setting['save_function'] ) ) { 
  34. if( isset( $form_id ) and $form_id != '' ) { 
  35. $arguments['form_id'] = $form_id; 
  36. $arguments['data'] = $data_array; 
  37. if( $setting['save_function'] != '' ) { 
  38. if( $ninja_forms_admin_update_message != '' ) { 
  39. $ninja_forms_admin_update_message .= ' '; 
  40. $ninja_forms_admin_update_message .= call_user_func_array($setting['save_function'], $arguments); 
  41. do_action( 'ninja_forms_save_admin_metabox_option', $setting, $form_id, $data_array ); 
  42.  
  43. if( isset( $opts['save_function'] ) ) { 
  44. $save_function = $opts['save_function']; 
  45. $arguments = func_get_args(); 
  46. array_shift($arguments); // We need to remove the first arg ($function_name) 
  47. if ( isset( $form_id ) and $form_id != '' ) { 
  48. $arguments['form_id'] = $form_id; 
  49. $arguments['data'] = $data_array; 
  50. if($save_function != '') { 
  51. if( $ninja_forms_admin_update_message != '' ) { 
  52. $ninja_forms_admin_update_message .= ' '; 
  53. $ninja_forms_admin_update_message .= call_user_func_array($save_function, $arguments); 
  54. do_action( 'ninja_forms_save_admin_metabox', $slug, $form_id, $data_array ); 
  55.  
  56.  
  57.  
  58. // Get the save function of our current sidebars, if present, and call them, passing the data that has been posted. 
  59. if(isset($ninja_forms_sidebars[$current_page][$current_tab]) AND is_array($ninja_forms_sidebars[$current_page][$current_tab])) { 
  60. foreach($ninja_forms_sidebars[$current_page][$current_tab] as $slug => $sidebar) { 
  61. if($sidebar['save_function'] != '') { 
  62. $save_function = $sidebar['save_function']; 
  63. $arguments = func_get_args(); 
  64. array_shift($arguments); // We need to remove the first arg ($function_name) 
  65. if ( isset( $form_id ) and $form_id != '' ) { 
  66. $arguments['form_id'] = $form_id; 
  67. $arguments['data'] = $data_array; 
  68. if($save_function != '') { 
  69. if( $ninja_forms_admin_update_message != '' ) { 
  70. $ninja_forms_admin_update_message .= ' '; 
  71. $ninja_forms_admin_update_message .= call_user_func_array($save_function, $arguments); 
  72. do_action( 'ninja_forms_save_admin_sidebar', $slug, $form_id, $data_array ); 
  73.  
  74. // Get the save function of our current tab and call it, passing the data that has been posted. 
  75. $save_function = $ninja_forms_tabs[$current_page][$current_tab]['save_function']; 
  76. $tab_reload = $ninja_forms_tabs[$current_page][$current_tab]['tab_reload']; 
  77. $arguments = func_get_args(); 
  78. array_shift($arguments); // We need to remove the first arg ($function_name) 
  79. if ( isset( $form_id ) and $form_id != '' ) { 
  80. $arguments['form_id'] = $form_id; 
  81. $arguments['data'] = $data_array; 
  82.  
  83. if($save_function != '') { 
  84.  
  85. $ninja_forms_admin_update_message = call_user_func_array($save_function, $arguments); 
  86. do_action( 'ninja_forms_save_admin_tab', $current_tab, $form_id, $data_array ); 
  87. if ( $tab_reload ) { 
  88. $redirect_array = array( 'update_message' => urlencode( $ninja_forms_admin_update_message ) ); 
  89. $url = esc_url_raw( add_query_arg( $redirect_array ) ); 
  90. wp_redirect( $url );