Skip to content

Instantly share code, notes, and snippets.

@dabernathy89
Last active December 23, 2015 07:19
Show Gist options
  • Save dabernathy89/6599932 to your computer and use it in GitHub Desktop.
Save dabernathy89/6599932 to your computer and use it in GitHub Desktop.
Add class(es) to Gravity Forms buttons
add_filter("gform_submit_button", "alter_form_submit_button", 10, 2);
function alter_form_submit_button($button, $form){
if ($form["button"]["type"] == "text") {
// (class=) followed by (single or double quote) followed by (anything that is not a single or double quote)
$pattern = '/(class=)(\'|")([^\'"]+)/';
$replacement = '${1}${2}${3} btn';
$newbutton = preg_replace($pattern, $replacement, $button);
if ( !is_null($newbutton) ) {
return $newbutton;
}
}
return $button;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment