Skip to content

Instantly share code, notes, and snippets.

@taotiwordpress
Last active August 20, 2021 17:47
Show Gist options
  • Save taotiwordpress/becac260047ca146796cabb9107c3c52 to your computer and use it in GitHub Desktop.
Save taotiwordpress/becac260047ca146796cabb9107c3c52 to your computer and use it in GitHub Desktop.
[Change Gravity forms fields markup] For fancy radios and checkboxes
<?php
add_filter( 'gform_field_choice_markup_pre_render', function ( $choice_markup, $choice, $field, $value ) {
if ( $field->get_input_type() == 'radio') {
return str_replace( "<label", "<span class='faux-radio'></span><label", $choice_markup );
}
if ( $field->get_input_type() == 'checkbox') {
return str_replace( "<label", "<span class='faux-checkbox'></span><label", $choice_markup );
}
return $choice_markup;
}, 10, 4 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment