#20088 closed enhancement (fixed)
Improve wp_list_comments() comment markup
Reported by: | lancewillett | Owned by: | markjaquith |
---|---|---|---|
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 )
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 div
s.
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 useesc_url
instead ofhtmlspecialchars
- 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
Attachments (9)
Change History (34)
#2
@
13 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
.
#3
@
13 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.
#5
@
13 years ago
I redid my changes after a bunch of testing on WP.com, with themes that do not have a custom comment callback.
The patch now is back to simply improving code quality, and only adding in classes and markup, not changing existing markup and styles.
#6
@
13 years ago
New patch handles back compat for pingbacks/trackbacks.
Found a small issue for back compat: the pingback element should be a div with class of "comment-body" so that previous styles won't break.
Props chellycat (Michelle Langston) for help in testing and for catching the pingback class issue.
Tested with themes that don't use a custom comments callback: Brand New Day, Chunk, Clean Home, Contempt, Dusk to Dawn, Fleur, Greyzed, Grid Focus, Manifest, Oulipo, Quintus, Retro Mac OS, Selecta, Structure, and Wu Wei.
#7
follow-up:
↓ 8
@
13 years ago
- Cc obenland@… added
Out of curiosity (in 20088.3.diff):
- Is there a reason you used
esc_html()
rather thanesc_url()
on line 1374? - Would it make sense to use
wp_parse_args()
on line 1388?
#8
in reply to:
↑ 7
@
12 years ago
Replying to kobenland:
- Is there a reason you used
esc_html()
rather thanesc_url()
on line 1374?
Good eye, fixed in new patch.
- Would it make sense to use
wp_parse_args()
on line 1388?
I don't think it helps in this case. What do you think is the benefit?
#9
@
12 years ago
I thought for consistency with how merging arguments in WP is handled. But you're right, it'll use array_merge()
anyway at some point.
#10
@
12 years ago
- Milestone changed from Awaiting Review to 3.5
We need this to not change any existing themes. That means new arguments for wp_list_comments().
Thoughts:
- You can currently specify 'style' => div, ol, or ul. You should also be able to specify tags and wrappers to the point where you can re-create the markup in Twenty Twelve.
- Repositioning the body inside a div might require a wrapper => false by default.
- For pingbacks, you should be able to specify 'ping_style' => 'concise' or something along those lines.
- We may be able to get away with converting <em class="comment-awaiting-moderation"></em><br /> to <p class="comment-awaiting-moderation"></p>. May.
Beyond those rough guidelines put together in about 5 minutes, I'd just see what you can come up with.
#12
@
12 years ago
Added #22005 for Twenty Twelve compatibility. It's really close to freeze for 1.0 (today!) so we might need to punt.
#13
@
12 years ago
- Keywords has-patch added; needs-patch removed
Built 20088.5.diff off of Lance's patch and I think I hit four out of four on Nacin's guidelines. :)
Two things I'm not completely happy with yet:
- Naming of the new arguments for
wp_list_comments()
- Switch of the old and new way of displaying the comment meta part
I'd love to hear you opinions!
#18
@
12 years ago
- Keywords dev-feedback added
New patch, introducing protected methods for better back/forward compat.
#19
@
12 years ago
See also #23128 for retrofitting Twenty Twelve a bit, for better "bypostauthor" comment markup.
#21
@
12 years ago
(Patch attached changed 'markup' argument default from empty string to xhtml and tweaked the comment a touch.
No functional changes.
comment-awaiting-moderation was added in #15206. I agree that the <br/> is lame.
Curious to hear about any backwards compatibility concerns and considerations.