skipv1_0_0form_save_fields

Skip form save function.

Description

skip\v1_0_0\form_save_fields(); 

Usage

  1. if ( !function_exists( 'skip\v1_0_0\form_save_fields' ) ) { 
  2. require_once '/includes/skip/elements/forms/form.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = skip\v1_0_0\form_save_fields(); 
  7.  

Defined (1)

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

/includes/skip/elements/forms/form.php  
  1. function form_save_fields() { 
  2. global $wpdb; 
  3.  
  4. $skip_form_save_fields = get_option( 'skip_form_save_field_array' ); 
  5.  
  6. if( is_array( $skip_form_save_fields ) ): // If there is any data to save 
  7. foreach( $skip_form_save_fields AS $form_name => $form_fields ): // Getting form name and fields of form 
  8. if( array_key_exists( $form_name . '_value', $_POST ) ): // If there was posted something 
  9. if ( wp_verify_nonce( $_POST[ $form_name . '_wpnonce' ], 'skip_form_' . $form_name ) ): // Verifying form 
  10.  
  11. // Running all fields 
  12. foreach( $form_fields AS $field ): 
  13. // If field name is in _POST data 
  14. if( array_key_exists( $field['name'], $_POST[ $form_name . '_value' ] ) ): 
  15. $new_value = ''; 
  16.  
  17. $value = $_POST[ $form_name . '_value' ][ $field[ 'name' ] ]; 
  18.  
  19. // Getting Value if it's an array 
  20. if( is_array( $value ) && '' != $field[ 'array' ] ): 
  21. $new_value = _cleanup_value( $value, $field[ 'array' ] ); 
  22. elseif ( !is_array( $value ) ): 
  23. $new_value = $value; 
  24. endif; 
  25.  
  26. // Saving if there is a value to save 
  27. if( '' != $new_value ): 
  28. update_option( $field[ 'option_name' ], $new_value ); 
  29. else: 
  30. delete_option( $field[ 'option_name' ] ); 
  31. endif; 
  32. else: 
  33. delete_option( $field[ 'option_name' ] ); 
  34. endif; 
  35. endforeach; 
  36. endif; 
  37. endif; 
  38.  
  39. endforeach; 
  40.  
  41. delete_option( 'skip_form_save_fields' ); 
  42.  
  43. endif; 
  44.