Skip to content

Instantly share code, notes, and snippets.

@josecarlospsh
Last active November 26, 2019 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josecarlospsh/dc7d7d557a10cb7850ffb997c29fa797 to your computer and use it in GitHub Desktop.
Save josecarlospsh/dc7d7d557a10cb7850ffb997c29fa797 to your computer and use it in GitHub Desktop.
Remove span tag from CF7
<?php
/*Remove <span></span> tag from Contact Form 7*/
add_filter('wpcf7_form_elements', function($content) {
$content = preg_replace('/<(span).*?class="\s*(?:.*\s)?wpcf7-form-control-wrap(?:\s[^"]+)?\s*"[^\>]*>(.*)<\/\1>/i', '\2', $content);
$content = str_replace('<br />', '', $content);
return $content;
});
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment