optionsframework_validate

Validate Options.

Description

optionsframework_validate( $input ); 

This runs after the submit/reset button has been clicked and validates the inputs.

Parameters (1)

0. $input
The input.

Usage

  1. if ( !function_exists( 'optionsframework_validate' ) ) { 
  2. require_once '/admin/options-framework/options-framework.php'; 
  3.  
  4. // The input. 
  5. $input = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = optionsframework_validate($input); 
  9.  

Defined (1)

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

/admin/options-framework/options-framework.php  
  1. function optionsframework_validate( $input ) { 
  2.  
  3. /** 
  4. * Restore Defaults. 
  5. * In the event that the user clicked the "Restore Defaults" 
  6. * button, the options defined in the theme's options.php 
  7. * file will be added to the option for the active theme. 
  8. */ 
  9.  
  10. if ( isset( $_POST['reset'] ) ) { 
  11. add_settings_error( 'options-framework', 'restore_defaults', __( 'Default options restored.', 'options_framework_theme' ), 'updated fade' ); 
  12.  
  13. /** 
  14. * Udpdate Settings. 
  15. */ 
  16.  
  17. if ( isset( $_POST['update'] ) ) { 
  18. $clean = array(); 
  19. $options = optionsframework_options(); 
  20. foreach ( $options as $option ) { 
  21.  
  22. if ( ! isset( $option['id'] ) ) { 
  23. continue; 
  24.  
  25. if ( ! isset( $option['type'] ) ) { 
  26. continue; 
  27.  
  28. $id = preg_replace( '/[^a-zA-Z0-9._\-]/', '', strtolower( $option['id'] ) ); 
  29.  
  30. // Set checkbox to false if it wasn't sent in the $_POST 
  31. if ( 'checkbox' == $option['type'] && ! isset( $input[$id] ) ) { 
  32. $input[$id] = '0'; 
  33.  
  34. // Set each item in the multicheck to false if it wasn't sent in the $_POST 
  35. if ( 'multicheck' == $option['type'] && ! isset( $input[$id] ) ) { 
  36. foreach ( $option['options'] as $key => $value ) { 
  37. $input[$id][$key] = '0'; 
  38.  
  39. // For a value to be submitted to database it must pass through a sanitization filter 
  40. if ( has_filter( 'of_sanitize_' . $option['type'] ) ) { 
  41. $clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option ); 
  42.  
  43. add_settings_error( 'options-framework', 'save_options', __( 'Options saved.', 'options_framework_theme' ), 'updated fade' ); 
  44. return $clean; 
  45.  
  46. /** 
  47. * Request Not Recognized. 
  48. */ 
  49.