bbp_encode_bad( string $content = '' )
Filter the content and encode any bad HTML tags
Description
Parameters
- $content
-
(Optional) Topic and reply content
Default value: ''
Return
(string) Partially encodedd content
Source
File: bp-forums/common/formatting.php
function bbp_encode_bad( $content = '' ) {
// Setup variables
$content = _wp_specialchars( $content, ENT_NOQUOTES );
$content = preg_split( '@(`[^`]*`)@m', $content, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE );
$allowed = bbp_kses_allowed_tags();
$empty = array(
'br' => true,
'hr' => true,
'img' => true,
'input' => true,
'param' => true,
'area' => true,
'col' => true,
'embed' => true
);
// Loop through allowed tags and compare for empty and normal tags
foreach ( $allowed as $tag => $args ) {
$preg = $args ? "{$tag}(?:\s.*?)?" : $tag;
// Which walker to use based on the tag and arguments
if ( isset( $empty[$tag] ) ) {
array_walk( $content, 'bbp_encode_empty_callback', $preg );
} else {
array_walk( $content, 'bbp_encode_normal_callback', $preg );
}
}
// Return the joined content array
return implode( '', $content );
}
Changelog
| Version | Description |
|---|---|
| bbPress (r4641) | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.