bbp_get_sanitize_val

Return sanitized $_REQUEST value.

Description

(string) bbp_get_sanitize_val( (string) $request = '', (string) $input_type = 'text' ); 

Use the $input_type parameter to properly process the value. This ensures correct sanitization of the value for the receiving input.

Returns (string)

Sanitized value ready for screen display

Parameters (2)

0. $request — Optional. (string) => ''
Name of $_REQUEST to look for
1. $input_type — Optional. (string) => 'text'
Type of input. Default: text. Accepts: textarea|password|select|radio|checkbox

Usage

  1. if ( !function_exists( 'bbp_get_sanitize_val' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/template.php'; 
  3.  
  4. // Name of $_REQUEST to look for 
  5. $request = ''; 
  6.  
  7. // Type of input. Default: text. Accepts: 
  8. // textarea|password|select|radio|checkbox 
  9. $input_type = 'text'; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = bbp_get_sanitize_val($request, $input_type); 
  13.  

Defined (1)

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

/includes/common/template.php  
  1. function bbp_get_sanitize_val( $request = '', $input_type = 'text' ) { 
  2.  
  3. // Check that requested 
  4. if ( empty( $_REQUEST[$request] ) ) 
  5. return false; 
  6.  
  7. // Set request varaible 
  8. $pre_ret_val = $_REQUEST[$request]; 
  9.  
  10. // Treat different kinds of fields in different ways 
  11. switch ( $input_type ) { 
  12. case 'text' : 
  13. case 'textarea' : 
  14. $retval = esc_attr( stripslashes( $pre_ret_val ) ); 
  15. break; 
  16.  
  17. case 'password' : 
  18. case 'select' : 
  19. case 'radio' : 
  20. case 'checkbox' : 
  21. default : 
  22. $retval = esc_attr( $pre_ret_val ); 
  23. break; 
  24.  
  25. return apply_filters( 'bbp_get_sanitize_val', $retval, $request, $input_type );