Have you ever tried to add a custom class to the Submit
button at the end of the standard WordPress comment form? It should be a very easy thing to do, but up until recently, you had to use one of several hacks to achieve this. WordPress core always did allow you to change almost all of the comment form’s elements, except for the button’s class.
As of WordPress 4.1, a patch has been accepted into core that finally allows you to change the class as easily as you could change the ID. You can read all the details on the ticket and it’s patch here: http://core.trac.wordpress.org/ticket/20446.
Now it’s very straightforward to change the class. Here’s an example that adds the classes button
and radius
to the button. These are defined in the Foundation framework and add a nice modern look to my Submit
button.
The code is heavily documented and should be self-explanatory. It is a simple WordPress filter on comment_form_defaults
that modifies an array and passes it on.
This is a very welcome change for all the WordPress developers that use front-end frameworks like Foundation or Bootstrap for their custom theme development.
Happy styling!