Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Last active April 14, 2020 06:52
Show Gist options
  • Save rafaehlers/55416ab7ec8b5ba145ff4f2dade3e6d5 to your computer and use it in GitHub Desktop.
Save rafaehlers/55416ab7ec8b5ba145ff4f2dade3e6d5 to your computer and use it in GitHub Desktop.
Prevents the wpautop (BR and P tags) function from running on a custom content field.
<?php
/**
* Remove wpautop() when Gravity Forms is in the field content
*/
add_filter( 'gravityview/field_output/args', function( $args, $passed_args, $context = null ) {
if( $context && $context instanceof \GV\Template_Context ) {
$content = \GV\Utils::get( $args, 'value', '' );
if( has_shortcode( $content, 'gravityform') ) {
$args['wpautop'] = false;
}
}
return $args;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment