Wordpress - How to add a class to the comment submit button?

From WordPress Version 4.1 (trac ticket #20446) it's now added to pass your own class as an argument of comment_form($args) using 'class_submit' array key:

$args = array( 'class_submit' => 'btn btn-default' );

No need to do extra hard work. (Edited the Codex too) :)


I'm working with the Foundation framework as well. I've found that the easiest way to add a class to a non-filterable element is to do it with jQuery.

jQuery(document).ready(function($) { //noconflict wrapper
    $('input#submit').addClass('button');
});//end noconflict

If you check out the source of the function comment_form(), you'll see it doesn't even print a class on the input;

<input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" />

I'm guessing you need to add a class for styling? Why not modify your CSS to just;

input.submit, #buttonPro {
    /* some awesome style */
}

Otherwise I guess the 'easiest' solution would be to simply copy the function to your functions.php, rename it, add in a class argument & print, and use that instead - which you can find here ;)