Make WordPress Core

Opened 7 years ago

Last modified 7 years ago

#40786 reopened defect (bug)

Leading spaces are added to custom textarea metabox

Reported by: subrataemfluence's profile subrataemfluence Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.5
Component: Posts, Post Types Keywords:
Focuses: administration Cc:


I am using esc_atr(ltrim(rtrim(br2nl($meta_value)))) to place the value of post meta in textarea metabox I have created in my custom post type.

<textarea id="<?php echo $id_name; ?>"
   name="<?php echo $id_name; ?>"
   rows="7" cols="80"
   style="width:100%" maxlength="<?php echo $maxlength; ?>"
   placeholder="<?php echo $placeholder_text; ?>"
   <?php if($is_required){ ?>required<?php } ?>>
   <?php echo esc_attr(ltrim( rtrim( br2nl($input_value)) ) ); ?>

But whenever I go to edit the post, inside all textarea metaboxes values are pre-loaded with leading spaces (exactly 10 spaces) and additional line breaks!

Also tried esc_atr(trim(br2nl($meta_value))) with no avail.

Attachments (1)

leading-space-extra-line-breaks.png (51.8 KB) - added by subrataemfluence 7 years ago.
Leading spaces and extra line breaks

Download all attachments as: .zip

Change History (4)

7 years ago

Leading spaces and extra line breaks

#1 @kebbet
7 years ago

  • Resolution set to invalid
  • Status changed from new to closed

Hello @subrataemfluence,
Sorry for the trouble you currently have but this Trac is only used for enhancements and bug reporting for the WordPress core software.
Our support forums are a better place to get help with your issue:

#2 @subrataemfluence
7 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened

I believe this is something related to core. I did not use any plugin to create the custom post type and it was done pure WP way.

#3 @truongwp
7 years ago

You should remove new line or space between the <textarea> open tag and textarea content

<textarea>Hello world</textarea>

instead of

   Hello world
Note: See TracTickets for help on using tickets.