Last active
March 24, 2021 10:46
-
-
Save eolant/d94a0f45b275b781bb05c51ea165eff4 to your computer and use it in GitHub Desktop.
Contact form 7 Bootstrap 4 custom radio and checkbox buttons filter to remove spans and change HTML structure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adjust contact form 7 radios and checkboxes to match bootstrap 4 custom radio structure. | |
*/ | |
add_filter('wpcf7_form_elements', function ($content) { | |
$content = preg_replace('/<label><input type="(checkbox|radio)" name="(.*?)" value="(.*?)" \/><span class="wpcf7-list-item-label">/i', '<label class="custom-control custom-\1"><input type="\1" name="\2" value="\3" class="custom-control-input"><span class="wpcf7-list-item-label custom-control-label">', $content); | |
return $content; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment