In bbPress, there is this annoying little backtick behavior, which can be an issue when you try to post code, specifically when using shell statements that actually have a backtick in it.
There is no easy way to disable that behavior ... except for modifying a core file of the bbPress plugin (bbPress 2.x).
Open the file
wp-content/plugins/bbpress/includes/common/formatting.php
Find where the function "bbp_code_trick" is defined and make the following changes:
(two slashes to comment out the two "$content = preg_replace_callback" lines)
function bbp_code_trick( $content = '' ) {
$content = str_replace( array( "rn", "r" ), "n", $content );
//$content = preg_replace_callback( "|(`)(.*?)`|", 'bbp_encode_callback', $content );
//$content = preg_replace_callback( "!(^|n)`(.*?)`!s", 'bbp_encode_callback', $content );
return $content;
}
Do the same with the function that is defined right after that:
(two slashes in front of the one line that says "$content = preg_replace_callback")
function bbp_code_trick_reverse( $content = '' ) {
// Setup variables
$openers = array( '<p>', '<br />' );
//$content = preg_replace_callback( "!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", 'bbp_decode_callback', $content );
// Do the do
$content = str_replace( $openers, '', $content );
$content = str_replace( '</p>', "n", $content );
$content = str_replace( '<coded_br />', '<br />', $content );
$content = str_replace( '<coded_p>', '<p>', $content );
$content = str_replace( '</coded_p>', '</p>', $content );
return $content;
}
Backticks as of now do not work anymore.
Caution:
- This "patch" needs to be done each time you update bbPress - so don't forget doing that.
- You might need to modify some parts of the theme where it might say something like "use backticks to mark code" - just so users don't accidentally use it.
- Your editor (fancy editor for example, or your custom editor) will need to use a < PRE > or < CODE > tag to mark code.