Opened 7 years ago
Closed 4 years ago
#41009 closed enhancement (fixed)
Add filter to comment form class
Reported by: | cjbj | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Comments | Keywords: | has-patch |
Focuses: | Cc: |
Description
Almost all html of the comment_form function can be customized using filters, except for this line (current 2285 in comment-template.php), which is the wrapping div of the comment form:
<div id="respond" class="comment-respond">
I feel there are legitimate reasons for wanting at least the class to be filterable. For instance if you are using the clearfix class throughout your design to clear floats. So I would like to propose changing this line to this:
$respond_class = 'comment-respond'; $respond_class = apply_filters ('comment_form_respond_class' ,$respond_class); echo '<div id="respond" class="' . esc_attr($respond_class) . '">';
Attachments (2)
Change History (9)
#4
follow-up:
↓ 6
@
5 years ago
- Keywords needs-patch added; has-patch commit removed
- Milestone changed from Future Release to 5.5
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
Thanks for the patch!
Instead of a filter, I think this would make more sense as a new argument for the comment_form()
function, for consistency with the existing class_form
and class_submit
arguments.
#5
@
5 years ago
That makes sense. It would still be filterable through 'comment_form_defaults' for less experienced developers.
#6
in reply to:
↑ 4
@
4 years ago
- Keywords has-patch added; needs-patch removed
I've added an argument "class_respond" to the comment_form() function. I hope this should do.
Replying to SergeyBiryukov:
Thanks for the patch!
Instead of a filter, I think this would make more sense as a new argument for the
comment_form()
function, for consistency with the existingclass_form
andclass_submit
arguments.
I have tested this patch and it works very well. Allowing a filter for the class of the comment wrapper is indeed a minor enhancement, but nevertheless a logical one considering that almost all the other parts of that form are filterable.