wp_kses_bad_protocol_once

Sanitizes content from bad protocols and other characters.

Description

(string) wp_kses_bad_protocol_once( (string) $string, (string) $allowed_protocols, (int) $count = 1 ); 

This function searches for URL protocols at the beginning of $string, while handling whitespace and HTML entities.

Returns (string)

Sanitized content

Parameters (3)

0. $string (string)
Content to check for bad protocols
1. $allowed_protocols (string)
The allowed protocols.
2. $count — Optional. (int) => 1
The count.

Usage

  1. if ( !function_exists( 'wp_kses_bad_protocol_once' ) ) { 
  2. require_once ABSPATH . WPINC . '/kses.php'; 
  3.  
  4. // Content to check for bad protocols 
  5. $string = ''; 
  6.  
  7. // The allowed protocols. 
  8. $allowed_protocols = ''; 
  9.  
  10. // The count. 
  11. $count = 1; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = wp_kses_bad_protocol_once($string, $allowed_protocols, $count); 
  15.  

Defined (1)

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

/wp-includes/kses.php  
  1. function wp_kses_bad_protocol_once($string, $allowed_protocols, $count = 1 ) { 
  2. $string2 = preg_split( '/:|�*58;|�*3a;/i', $string, 2 ); 
  3. if ( isset($string2[1]) && ! preg_match('%/\?%', $string2[0]) ) { 
  4. $string = trim( $string2[1] ); 
  5. $protocol = wp_kses_bad_protocol_once2( $string2[0], $allowed_protocols ); 
  6. if ( 'feed:' == $protocol ) { 
  7. if ( $count > 2 ) 
  8. return ''; 
  9. $string = wp_kses_bad_protocol_once( $string, $allowed_protocols, ++$count ); 
  10. if ( empty( $string ) ) 
  11. return $string; 
  12. $string = $protocol . $string; 
  13.  
  14. return $string;