twentyeleven_theme_options_validate

Sanitize and validate form input.

Description

twentyeleven_theme_options_validate( $input ); 

Accepts an array, return a sanitized array.

Parameters (1)

0. $input
The input.

Usage

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

Defined (1)

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

/inc/theme-options.php  
  1. function twentyeleven_theme_options_validate( $input ) { 
  2. $output = $defaults = twentyeleven_get_default_theme_options(); 
  3.  
  4. // Color scheme must be in our array of color scheme options 
  5. if ( isset( $input['color_scheme'] ) && array_key_exists( $input['color_scheme'], twentyeleven_color_schemes() ) ) 
  6. $output['color_scheme'] = $input['color_scheme']; 
  7.  
  8. // Our defaults for the link color may have changed, based on the color scheme. 
  9. $output['link_color'] = $defaults['link_color'] = twentyeleven_get_default_link_color( $output['color_scheme'] ); 
  10.  
  11. // Link color must be 3 or 6 hexadecimal characters 
  12. if ( isset( $input['link_color'] ) && preg_match( '/^#?([a-f0-9]{3}) {1, 2}$/i', $input['link_color'] ) ) 
  13. $output['link_color'] = '#' . strtolower( ltrim( $input['link_color'], '#' ) ); 
  14.  
  15. // Theme layout must be in our array of theme layout options 
  16. if ( isset( $input['theme_layout'] ) && array_key_exists( $input['theme_layout'], twentyeleven_layouts() ) ) 
  17. $output['theme_layout'] = $input['theme_layout']; 
  18.  
  19. return apply_filters( 'twentyeleven_theme_options_validate', $output, $input, $defaults );