Skip to main content
Articles

Disable ACF Unsafe HTML Rendering

72
1

ACF now automatically escapes unsafe HTML (Vague Term) when rendered by the_field or the ACF shortcode.

It throws a message at the top of posts and pages where it’s detected issues that says, “We’ve detected the output of some of your fields has been modified by this change, but this may not be a breaking change. Learn more. Show details.”

This has let to quite a bit of 911 madness for developers using automatic updates who woke up to broken website not rendering output data correctly, and confusing messages for developers and agency clients.

Here’s the quick fix:

This will disable the notice:


add_filter( 'acf/admin/prevent_escaped_html_notice', '__return_true' );

This will ALLOW unsafe HTML to be rendered.


add_filter( 'acf/the_field/allow_unsafe_html', function( $allowed, $selector ) {
    return true;
    return $allowed;
}, 10, 2);

Note: There are actually real world cases for rendering “unsafe” HTML. Unsafe basically includes non-standard HTML entities. If thats the case, then this works. But you should always check to make sure you’re not rendering potential bad actors like iframes or scripts.

Corner Icon Render
Corner Icon Render
Corner Icon Render
Corner Icon Render How Can I Help You?