bbp_encode_callback

Callback to encode the tags in topic or reply content.

Description

(string) bbp_encode_callback( (array) $matches = array() ); 

Returns (string)

Parameters (1)

0. $matches — Optional. (array) => array()
The matches.

Usage

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

Defined (1)

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

/includes/common/formatting.php  
  1. function bbp_encode_callback( $matches = array() ) { 
  2.  
  3. // Trim inline code, not pre blocks (to prevent removing indentation) 
  4. if ( "`" === $matches[1] ) { 
  5. $content = trim( $matches[2] ); 
  6. } else { 
  7. $content = $matches[2]; 
  8.  
  9. // Do some replacing 
  10. $content = htmlspecialchars( $content, ENT_QUOTES ); 
  11. $content = str_replace( array( "\r\n", "\r" ), "\n", $content ); 
  12. $content = preg_replace( "|\n\n\n+|", "\n\n", $content ); 
  13. $content = str_replace( '&', '&', $content ); 
  14. $content = str_replace( '&lt;', '<', $content ); 
  15. $content = str_replace( '&gt;', '>', $content ); 
  16.  
  17. // Wrap in code tags 
  18. $content = '<code>' . $content . '</code>'; 
  19.  
  20. // Wrap blocks in pre tags 
  21. if ( "`" !== $matches[1] ) { 
  22. $content = "\n<pre>" . $content . "</pre>\n"; 
  23.  
  24. return $content;