Skip to content

Instantly share code, notes, and snippets.

@pixelstorm
Created August 25, 2024 00:13
Show Gist options
  • Save pixelstorm/b0777d676a9713f967602b43b9caabe5 to your computer and use it in GitHub Desktop.
Save pixelstorm/b0777d676a9713f967602b43b9caabe5 to your computer and use it in GitHub Desktop.
Adds two custom CSS classes to the submit button
add_filter( 'gform_submit_button', 'add_custom_css_classes', 10, 2 );
function add_custom_css_classes( $button, $form ) {
$dom = new DOMDocument();
$dom->loadHTML( $button );
$input = $dom->getElementsByTagName( 'input' )->item(0);
$classes = $input->getAttribute( 'class' );
$classes .= " my-custom-class another-one";
$input->setAttribute( 'class', $classes );
return $dom->saveHtml( $input );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment