Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#23878 closed defect (bug) (fixed)

comment_form function has inconsistent spacing between HTML elements in $fields array

Reported by: sim's profile sim Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 3.6 Priority: normal
Severity: trivial Version: 3.0
Component: Comments Keywords: has-patch commit
Focuses: Cc:


In function comment_form (wp-includes/comment-template.php) there are several default HTML strings which output the form fields for users entering comments to a post.

The first two, "author" and "email" have a space between the </label> and the <input> elements, whereas the following two fields "url" and "comment_field" (from $defaults) do not have spaces between these elements.

From comment-template.php
line 1524: '</label> ' .
line 1526: '</label> ' .
line 1528: '</label>' .
line 1535: '</label><textarea

Note the spaces after the label element in lines 1524 & 1526 which are lacking in lines 1528 and 1535.

Suggested fix: add a space after the label element on lines 1528 and 1535 for consistency.

In the Twenty Eleven and Twenty Twelve themes this does not manifest itself as a problem, since the label element is displayed as a block.

However, if your theme displays the label inline, it manifests itself as a difference in spacing between the first two and second two elements, which cannot be easily overcome with CSS.

While this is a trivial issue, it should be ideally fixed for consistency and to avoid the need for workarounds when comment labels are displayed inline.

Attachments (1)

comment-template.php.diff (2.4 KB) - added by TravisHoffman 11 years ago.
Added spaces after </label> in $fields and $defaults arrays

Download all attachments as: .zip

Change History (6)

#1 @nacin
11 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 3.6

I agree with the suggested fix.

#2 @TravisHoffman
11 years ago

  • Keywords has-patch added; needs-patch removed

Added the spaces in the $fields array on line 1619 of comment-template.php after </label> to remain consistent.

11 years ago

Added spaces after </label> in $fields and $defaults arrays

#3 @markoheijnen
11 years ago

  • Keywords commit added

#4 @SergeyBiryukov
11 years ago

  • Version changed from 3.5.1 to 3.0

Introduced in [13180].

#5 @SergeyBiryukov
11 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 23932:

Fix inconsistent spacing in comment_form(). props sim, TravisHoffman. fixes #23878.

Note: See TracTickets for help on using tickets.