Skip to:
Content

BuddyPress.org

Changeset 11895


Ignore:
Timestamp:
03/07/2018 12:27:57 PM (20 months ago)
Author:
djpaul
Message:

Emails: use wpautop() instead of nl2br() when rendering HTML email content.

When including markup in the email body, e.g. tables, these are usually saved by
the WordPress editor with newlines after each tag. These newlines get converted
by nl2br() to <br> tags. As <br> tags are not allowed between all elements,
e.g. <tr> and <td>, these get pulled in front of the table by most browsers
and email clients.

This leads to a lot of <br> tags in front of the table -- undesired whitespace.

Fixes #7706

Props chherbst

Location:
trunk/src/bp-core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-filters.php

    r11893 r11895  
    11321132    // Make sure we add a <title> tag so WP Customizer picks it up.
    11331133    $template = str_replace( '<head>', '<head><title>' . esc_html_x( 'BuddyPress Emails', 'screen heading', 'buddypress' ) . '</title>', $template );
    1134     echo str_replace( '{{{content}}}', nl2br( get_post()->post_content ), $template );
     1134    echo str_replace( '{{{content}}}', wpautop( get_post()->post_content ), $template );
    11351135
    11361136    /*
  • trunk/src/bp-core/classes/class-bp-email.php

    r10696 r11895  
    247247            // Special-case to fill the $template with the email $content.
    248248            case 'add-content':
    249                 $retval = str_replace( '{{{content}}}', nl2br( $this->get_content( 'replace-tokens' ) ), $retval );
     249                $retval = str_replace( '{{{content}}}', wpautop( $this->get_content( 'replace-tokens' ) ), $retval );
    250250                // Fall through.
    251251
Note: See TracChangeset for help on using the changeset viewer.