bbp_encode_callback( array $matches = array() )
Callback to encode the tags in topic or reply content
Description
Parameters
- $matches
-
(Optional)
Default value: array()
Return
(string)
Source
File: bp-forums/common/formatting.php
function bbp_encode_callback( $matches = array() ) { // Trim inline code, not pre blocks (to prevent removing indentation) if ( "`" === $matches[1] ) { $content = trim( $matches[2] ); } else { $content = $matches[2]; } // Do some replacing $content = htmlspecialchars( $content, ENT_QUOTES ); $content = str_replace( array( "\r\n", "\r" ), "\n", $content ); $content = preg_replace( "|\n\n\n+|", "\n\n", $content ); $content = str_replace( '&amp;', '&', $content ); $content = str_replace( '&lt;', '<', $content ); $content = str_replace( '&gt;', '>', $content ); // Wrap in code tags $content = '<code>' . $content . '</code>'; // Wrap blocks in pre tags if ( "`" !== $matches[1] ) { $content = "\n<pre>" . $content . "</pre>\n"; } return $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.