WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 8 weeks ago

#41009 reviewing enhancement

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)

41009.patch (677 bytes) - added by yahil 3 years ago.
41009.diff (2.1 KB) - added by mayankmajeji 8 weeks ago.
Comment respond class "class_repond" added to "comment-template.php" file.

Download all attachments as: .zip

Change History (8)

#1 @cjbj
3 years ago

  • Keywords has-patch added
  • Type changed from feature request to enhancement

@yahil
3 years ago

#2 @earnjam
11 months ago

  • Version 4.7 deleted

#3 @andraganescu
6 months ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to Future Release

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.

#4 follow-up: @SergeyBiryukov
2 months 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 @cjbj
2 months ago

That makes sense. It would still be filterable through 'comment_form_defaults' for less experienced developers.

@mayankmajeji
8 weeks ago

Comment respond class "class_repond" added to "comment-template.php" file.

#6 in reply to: ↑ 4 @mayankmajeji
8 weeks 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 existing class_form and class_submit arguments.

Note: See TracTickets for help on using tickets.