Re: How to show code in forum posts?
I got it at least…
What i need is the possibility to copy/paste some code in my forum posts.
The code on the pastebin is globally correct, but as boone says, “it’s not totally reliable”.
The first thing, i you want to use it, is to copy paste the given code into your child theme function.php file.
Then you add a filter to deactivate the (damned) default typographical double cote wp filter
remove_filter( ‘bp_get_the_topic_post_content’, ‘wptexturize’ );
here the code you find on pastebin
in the function bporg_decodeit, retrieve <code> in the if statement
`if ( ‘
' == $matches[1] )`
Should be
`if ( '' == $matches[1] )`
In the function bporg_code_trick, there are 4 backticks, we have to change this a little
In the first callback, replace the FIRST backstick by & # 96 ; (without space)
In the second callback, replace the SECOND backstick by & # 96 ; (without space)
That's it ! Now you can copy most of php code with backstick and the right double cotes.
view the result here:
http://bp-fr.net/groups/groupe-de-tests/forum/topic/php-complexe-test/