Opened 2 days ago
#66732 assigned enhancement
Comments: Allow comment types to register a display callback
| Reported by: | adamsilverstein | Owned by: | adamsilverstein |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.3 |
| Component: | Comments | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | template |
Description
Follow-up to #35214, which introduces register_comment_type(). Requested in comment:18:ticket:35214.
A custom comment type often should not render like a comment: a like, a repost or a webmention is closer to an avatar in a facepile than to a threaded reply. Today the only way to change rendering is the global callback argument of wp_list_comments(), which a theme owns and which applies to every type.
Proposal
Add a render_callback argument to register_comment_type(). When Walker_Comment renders a comment whose type has one, it calls it with the same arguments as a wp_list_comments() callback ($comment, $args, $depth).
- An explicit
callbackpassed towp_list_comments()still takes precedence, so themes keep control. - Built-in types register no callback, so their output is unchanged.
- The callback echoes, and opens the element without closing it, matching the existing
callbackcontract. Its output is not escaped by core.
Patch
https://github.com/adamsilverstein/wordpress-develop/pull/53 (stacked on the registration API branch; will be opened against trunk once that is committed).