WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 7 weeks ago

#20088 closed enhancement

Improve wp_list_comments() comment markup — at Version 4

Reported by: lancewillett Owned by:
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.3.1
Component: Comments Keywords: has-patch twentythirteen dev-feedback
Focuses: Cc:

Description (last modified by lancewillett)

The default comment markup generated by wp_list_comments() needs a small revamp. This will potentially help theme authors avoid using their own comment callback functions by incorporating a structure popularized by the last two default themes.

Twenty Twelve, for example, could almost drop the custom comments callback in functions.php with these improvements, with the exception of not being able to use HTML5 semantic elements instead of divs.

Patch has code cleanup and improvements to the comment-template.php file, including:

start_lvl()

  • Use double quotes for HTML output

end_lvl()

  • Add in .children end element HTML comments

start_el()

  • Add switch statement for handling pingback/trackback first, to run before "other" types of comments
  • Add pingback/trackback HTML output based on Twenty Ten / Eleven: much simpler than normal comments
  • Wrap comment_text() in a div element so it can be styled separately
  • Change comment-awaiting-moderation to be wrapped in a paragraph element, removing presentational line break
  • Use updated comment-meta data based on Twenty Ten / Eleven: include an author link (if it exists), better time/date formatting, and use esc_url instead of htmlspecialchars
  • Add in several end element HTML comments
  • Fix spacing around parens
  • Better indenting for PHP and HTML code throughout

end_el()

  • Fix spacing around parens
  • Add in #comment-## end element HTML comments

Change History (6)

lancewillett2 years ago

comment:1 nacin2 years ago

comment-awaiting-moderation was added in #15206. I agree that the <br/> is lame.

Curious to hear about any backwards compatibility concerns and considerations.

comment:2 lancewillett2 years ago

Back compat concerns are class and ID name changes, which I considered and tried to keep as minimal as possible.

If themes are not currently using a custom callback they might need small CSS tweaks to selectors for .comment-body.

comment:3 lancewillett2 years ago

Also, if this lands in trunk soonish, I could test it out with all the WP.com themes to see if there are serious back compat issues.

comment:4 lancewillett2 years ago

  • Description modified (diff)

lancewillett2 years ago

Second pass, revert changes to existing class values and markup

Note: See TracTickets for help on using tickets.