WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 5 months ago

#20446 closed enhancement (fixed)

Add comment form submit button class attribute

Reported by: bainternet Owned by: SergeyBiryukov
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.3.1
Component: Comments Keywords: has-patch
Focuses: Cc:

Description

The comment_form() is packed with filters all over the place to customize the from just the way you need, but one thing i find missing is a class on the submit input tag and if there was a class attribute then it should be filterable.

I know you can set the input ID and simply style based on the ID selector but when designing themes usually you have some kind of class defined for buttons, especially when using any of the html5/responsive theme frameworks and if the comment submit input had a class which was filterable then it would make our lives much easier.

Attachments (1)

comment_form.patch (1.4 KB) - added by bainternet 3 years ago.
patched comment_form function with submit class

Download all attachments as: .zip

Change History (17)

comment:1 @bainternet3 years ago

should be very simple , I'll upload a patch as soon as i get home.

@bainternet3 years ago

patched comment_form function with submit class

comment:2 @bainternet3 years ago

  • Keywords has-patch 2nd-opinion needs-testing added

Added patch to handle the comment form submit input class
ex:

comment_form(array('class_submit'=>'myclass'));

comment:3 @bainternet3 years ago

  • Keywords 2nd-opinion removed

comment:4 @coffee2code3 years ago

  • Version set to 3.3.1

Related: #15015 (patch there provides a solution that allows adding 'class' attribute to comment form submit button)

comment:5 @SergeyBiryukov21 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #15015.

comment:6 @ktabori13 months ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

Id is not a class and this ticket isn't duplicate.

It's a missed feature for templating, if you use bootstrap or other templating/css frameworks.

I have tested the patch and it works fine.

Last edited 13 months ago by ktabori (previous) (diff)

comment:7 @SergeyBiryukov12 months ago

#27232 was marked as a duplicate.

comment:8 follow-up: @SergeyBiryukov12 months ago

  • Keywords reporter-feedback added; needs-testing removed
  • Milestone set to Awaiting Review

Looking at the code, .comment-form input[type="submit"] should work for styling purposes:
tags/3.8.1/src/wp-includes/comment-template.php#L2120

Why do you need a specific class for that button?

comment:9 in reply to: ↑ 8 ; follow-up: @spacedmonkey12 months ago

Replying to SergeyBiryukov:

Looking at the code, .comment-form input[type="submit"] should work for styling purposes:
tags/3.8.1/src/wp-includes/comment-template.php#L2120

Why do you need a specific class for that button?

There are lots of reasons why you might want classes on a submit button. In my case, I need it because twitter bootstrap needs a class on all of it's submit buttons to get the correct styling.

comment:10 in reply to: ↑ 9 @iamdmitrymayorov12 months ago

Agree with spacedmonkey. No doubt that it is possible to style the button using the id. But if you are using bootstrap and less and do something like this:

#submit {
 .btn;
 .btn-primary;
}

After compiling, your css file becomes 2Kb heavier because all the bootstrap button styles are now applied one more time to our tiny button. If there was a possibility to add class this could be avoidable. I agree it's not 100% semantically correct but good in terms of saving bandwidth.

comment:11 @spacedmonkey12 months ago

Everything else in the form is overridable apart from this one thing. It seems like a small thing and the patch has already been written, I don't see the issue with added this extra functionality?

comment:12 @SergeyBiryukov6 months ago

#23281 was marked as a duplicate.

comment:13 @SergeyBiryukov6 months ago

  • Keywords reporter-feedback removed
  • Milestone changed from Awaiting Review to Future Release

comment:14 @rajlaksh6 months ago

Thank you for opening it :)

comment:15 @SergeyBiryukov5 months ago

  • Milestone changed from Future Release to 4.1
  • Owner set to SergeyBiryukov
  • Status changed from reopened to accepted

comment:16 @SergeyBiryukov5 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 29809:

Add a class attribute for submit button in comment form.

props bainternet.
fixes #20446.

Note: See TracTickets for help on using tickets.