• Resolved Sander Rebry

    (@stwebvision)


    Hi, I found an issue in ACF Text block rendering for WYSIWYG fields.

    Current code in inc/blocks/class-acf-text.php:
    case ‘wysiwyg’:
    $tag = ‘div’;
    $value = wp_kses_post( nl2br( $field[‘value’] ) );
    break;

    Problem:

    nl2br() injects unnecessary around block-level HTML.
    – WYSIWYG content (paragraphs/lists) can lose expected structure or get polluted output.

    Expected:

    – WYSIWYG should be processed with ACF/WP content formatting (e.g. apply_filters('acf_the_content', $value)), not nl2br().

    Repro:
    1) Create ACF WYSIWYG field with multiple paragraphs
    2) Render via ACF Field block (Text)
    3) Frontend output contains extra / incorrect paragraph structure.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author gamaup

    (@gamaup)

    Hi,

    Thank you very much for reporting this and for the detailed explanation, including the repro steps. I really appreciate it.

    You’re absolutely right about nl2br() not being ideal for WYSIWYG fields, especially when the content already contains proper block-level HTML. It makes sense to let WordPress or ACF handle the formatting instead of manually injecting line breaks.

    I will update this in the next release to ensure WYSIWYG fields are processed using the proper content filters rather than nl2br().

    Thanks again for taking the time to point this out.

    Thread Starter Sander Rebry

    (@stwebvision)

    Hi,

    thanks for the quick confirmation and for planning a fix.
    Great to hear this will be corrected in the next release.

    • This reply was modified 4 months, 1 week ago by Sander Rebry.
Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.