Opened 9 years ago
Closed 6 years ago
#41009 closed enhancement (fixed)
Add filter to comment form class
| Reported by: | cjbj | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.5 |
| Component: | Comments | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
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
@
6 years ago
- Keywords needs-patch added; has-patch commit removed
- Milestone Future Release → 5.5
- Owner set to
- Status new → 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
@
6 years ago
That makes sense. It would still be filterable through 'comment_form_defaults' for less experienced developers.
#6
in reply to: ↑ 4
@
6 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_formandclass_submitarguments.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.