bbp_encode_bad

Filter the content and encode any bad HTML tags.

Description

(string) bbp_encode_bad( (string) $content = '' ); 

Returns (string)

Partially encodedd content

Parameters (1)

0. $content — Optional. (string) => ''
Topic and reply content

Usage

  1. if ( !function_exists( 'bbp_encode_bad' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/formatting.php'; 
  3.  
  4. // Topic and reply content 
  5. $content = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_encode_bad($content); 
  9.  

Defined (1)

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

/includes/common/formatting.php  
  1. function bbp_encode_bad( $content = '' ) { 
  2.  
  3. // Setup variables 
  4. $content = _wp_specialchars( $content, ENT_NOQUOTES ); 
  5. $content = preg_split( '@(`[^`]*`)@m', $content, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE ); 
  6. $allowed = bbp_kses_allowed_tags(); 
  7. $empty = array( 
  8. 'br' => true,  
  9. 'hr' => true,  
  10. 'img' => true,  
  11. 'input' => true,  
  12. 'param' => true,  
  13. 'area' => true,  
  14. 'col' => true,  
  15. 'embed' => true 
  16. ); 
  17.  
  18. // Loop through allowed tags and compare for empty and normal tags 
  19. foreach ( $allowed as $tag => $args ) { 
  20. $preg = $args ? "{$tag}(?:\s.*?)?" : $tag; 
  21.  
  22. // Whichwalkerto use based on the tag and arguments 
  23. if ( isset( $empty[$tag] ) ) { 
  24. array_walk( $content, 'bbp_encode_empty_callback', $preg ); 
  25. } else { 
  26. array_walk( $content, 'bbp_encode_normal_callback', $preg ); 
  27.  
  28. // Return the joined content array 
  29. return implode( '', $content );