[wp-trac] [WordPress Trac] #46188: esc_html does not have support for multiline output. esc_br_html or line-breaking parameter for esc_html is missing

WordPress Trac noreply at wordpress.org
Sat Mar 2 04:59:45 UTC 2019


#46188: esc_html does not have support for multiline output. esc_br_html or line-
breaking parameter for esc_html is missing
-------------------------+------------------------------
 Reporter:  KestutisIT   |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Formatting   |     Version:  5.0.3
 Severity:  normal       |  Resolution:
 Keywords:  needs-patch  |     Focuses:  template
-------------------------+------------------------------

Comment (by timph):

 In HTML you can preserve linebreaks using CSS, commonly it's used on a pre
 element, but could be used where you might see fit by setting the white-
 space property's value to pre.  This would give you a similar style as
 replacing the newline with a <br /> in your example.

 In WordPress there is already a function to handle similar formatting to
 replace newlines with breaks and to replace double new lines with
 paragraphs. wpautop:
 [https://developer.wordpress.org/reference/functions/wpautop/].

 If your user is entering it in some sort of textarea field and you're
 wanting them to have a visual representation there's the wp_editor()
 function to create a visual editor (tinymce instance), and one of the
 configurations you can pass in is for wpautop behavior.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46188#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list