[wp-trac] [WordPress Trac] #40786: Leading spaces are added to custom textarea metabox

WordPress Trac noreply at wordpress.org
Sun Sep 14 16:50:24 UTC 2025


#40786: Leading spaces are added to custom textarea metabox
-------------------------------+-----------------------------
 Reporter:  subrataemfluence   |       Owner:  (none)
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:  invalid
 Keywords:                     |     Focuses:  administration
-------------------------------+-----------------------------
Changes (by SirLouen):

 * status:  reopened => closed
 * version:  4.7.5 =>
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 You cannot simply add HTML code with the identation you like in the code
 and not find unexpected behaviour like this. As @truongwp has commented,
 one solution is just doing a one liner for the `textarea` part

 Another solution is to use `ob_start`
 Like this:

 {{{
 ob_start();
 echo esc_attr(ltrim(rtrim(br2nl($input_value))));
 $textarea_content = ob_get_clean();
 echo trim($textarea_content);
 }}}

 Inside the `textarea` section, then you can maintain your textarea
 indentation.

 Closing this ticket as its more of a support ticket for the forums than an
 issue for Trac.

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


More information about the wp-trac mailing list