Skip to:

Line Break

  • I’m new to bbpress, and was playing around with an install. I noticed that it doesn’t allow all forms of line breaks, only the current proper one that is self closing.

    <br> and <BR>

    Do not seem to work properly. This was an issue because I noticed that my users are sloppy HTML coders and the tags would just print out.

    I don’t know if it has been covered before. I searched and found nothing. I did get it to work with a small php tweak.

    In formatting-functions.php, I put the following under bb_encode_bad:

    $text = preg_replace('|& lt;BR& gt;|', '', $text);
    $text = preg_replace('|& lt;br& gt;|', '', $text);
    $text = preg_replace('|& lt;br /& gt;|', '', $text)

    (The code tag won’t output the code correctly, so I put a space after the &, so they wouldn’t get converted.)

    It works, but all three forms now convert to<br>, instead of

    Which works well enough, but even self closing br tags will now drop the /

    I’m not strong at PHP. Only enough to get by. What do you think. Is there another way to do it? Or a better way? Or hell, a plugin?

Viewing 4 replies - 1 through 4 (of 4 total)

  • _ck_


    Doesn’t your code zap all BRs?

    This is not quite what you are trying to do, but maybe you can add BR to this list and see if bbpress will bypass the self-closing requirement.

    function bb_allow_extra_tags( $tags ) {
    $tags['del'] = array();
    $tags['strike'] = array();
    $tags['s'] = array();
    $tags['b'] = array();
    $tags['i'] = array();
    $tags['u'] = array();
    $tags['bq'] = array();
    $tags['blockquote'] = array();
    $tags['pre'] = array();
    $tags['hr'] = array();
    $tags['br'] = array(); // see if this allows non-closed br
    $tags['BR'] = array(); // see if this allows uppercase BR
    return $tags;
    add_filter( 'bb_allowed_tags', 'bb_allow_extra_tags' );

    As far as uppercase/lowercase that would be tricker if it’s hard coded in the code. You’d have to filter the post text ahead of time, find all tags and convert them to lowercase. Or try adding $tags['BR'] = array(); to the above list and see if that makes a difference.

    Personally I’d just add the bbcode plugin if you’ve got people trying to make fancier posts. It’s far more common across all forums.



    I think I better understand what you are asking about after running into a similar problem today on my bbcode lite plugin. I filed a trac ticket:

    bbPress seems to encode non-ending tags into html entities if you save a post twice. Not good.

    I ran into the problem when using imagevenue, a popular image host.

    It breaks the rows by using <BR>

    For me, it’d work fine since I have the plugin to let me post anything, but for users, it outputs the link break code and threats the <BR> as a tag that isn’t allowed.

    I’ll play around with the changes. And the stuff you suggest. I have it working well enough for now, just not “exactly” what I wanted.

    Thanks for the advice _ck_

    Love your plugins btw, great job on them.



    I’ve decided to try to tackle the non-ending bug and it might make the next release on March 10th.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar