Support » Theme: Customizr » Enabling newlines / linebreaks / carriage returns in comments

  • This is a tip / howto for people who would like for newlines / linebreaks left in comments to actually appear. πŸ™‚

    With customizr, newlines in comments are ignored, and all comments are displayed as single paragraphs. For long comments this can be problematic.

    It took me a while to figure it out, but fortunately the fix is easy to apply.

    In the file wp-content/themes/customizr/parts/class-content-comments.php at around line 172, change the function invocation “get_comment_text()” to just “make_clickable(wpautop(get_comment_text()))”.

    get_comment_text() returns JUST the comment text from the database, including newlines, but the newlines are of course not shown by the browser. wpautop() turns the newlines into <p> tags. make_clickable() automatically makes URLs clickable in comments, which is an added convenience.

    To see this in action with long comments, go to http://vxlabs.com/2012/12/22/ssds-with-usable-built-in-hardware-based-full-disk-encryption/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Sounds like one for Nikeo’s wish list. Will flag it. Thanks.

    Theme Author presscustomizr

    (@nikeo)

    Thanks for this feedback @cpbotha. You are absolutely right.
    There is a built-in filter in WordPress to handle this : ‘comment_text’.
    The text of the comment can be get with get_comment_text() bus has to filtered with ‘comment_text’ to be displayed properly.

    Example of implementation in the comment’s callback function :

    apply_filters( 'comment_text', get_comment_text( $comment->comment_ID , $args ), $comment, $args );

    @electricfeet : this is implemented in the next release of the theme (3.1.6+)

    Wow! A 14 hour response on Xmas day and already included in the next release. This has to be a record of some sort…

    Theme Author presscustomizr

    (@nikeo)

    πŸ˜‰ welcome in a geek’s life…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Enabling newlines / linebreaks / carriage returns in comments’ is closed to new replies.