wp_kses_bad_protocol_once2

Callback for wp_kses_bad_protocol_once() regular expression.

Description

(string) wp_kses_bad_protocol_once2( (string) $string, (string) $allowed_protocols ); 

This function processes URL protocols, checks to see if they're in the whitelist or not, and returns different data depending on the answer.

Returns (string)

Sanitized content

Parameters (2)

0. $string (string)
URI scheme to check against the whitelist
1. $allowed_protocols (string)
The allowed protocols.

Usage

  1. if ( !function_exists( 'wp_kses_bad_protocol_once2' ) ) { 
  2. require_once ABSPATH . WPINC . '/kses.php'; 
  3.  
  4. // URI scheme to check against the whitelist 
  5. $string = ''; 
  6.  
  7. // The allowed protocols. 
  8. $allowed_protocols = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_kses_bad_protocol_once2($string, $allowed_protocols); 
  12.  

Defined (1)

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

/wp-includes/kses.php  
  1. function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) { 
  2. $string2 = wp_kses_decode_entities($string); 
  3. $string2 = preg_replace('/\s/', '', $string2); 
  4. $string2 = wp_kses_no_null($string2); 
  5. $string2 = strtolower($string2); 
  6.  
  7. $allowed = false; 
  8. foreach ( (array) $allowed_protocols as $one_protocol ) 
  9. if ( strtolower($one_protocol) == $string2 ) { 
  10. $allowed = true; 
  11. break; 
  12.  
  13. if ($allowed) 
  14. return "$string2:"; 
  15. else 
  16. return '';