bbp_code_trick_reverse

When editing a topic or reply, reverse the code trick so the textarea contains the correct editable content.

Description

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

Returns (string)

Partially encodedd content

Parameters (1)

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

Usage

  1. if ( !function_exists( 'bbp_code_trick_reverse' ) ) { 
  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_code_trick_reverse($content); 
  9.  

Defined (1)

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

/includes/common/formatting.php  
  1. function bbp_code_trick_reverse( $content = '' ) { 
  2.  
  3. // Setup variables 
  4. $openers = array( '<p>', '<br />' ); 
  5. $content = preg_replace_callback( "!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", 'bbp_decode_callback', $content ); 
  6.  
  7. // Do the do 
  8. $content = str_replace( $openers, '', $content ); 
  9. $content = str_replace( '</p>', "\n", $content ); 
  10. $content = str_replace( '<coded_br />', '<br />', $content ); 
  11. $content = str_replace( '<coded_p>', '<p>', $content ); 
  12. $content = str_replace( '</coded_p>', '</p>', $content ); 
  13.  
  14. return $content;