Home Forums Gutenberg ACF block output breaks due to wp_kses() on woocommerce checkout page


ACF block output breaks due to wp_kses() on woocommerce checkout page

  • Hi,

    When the terms and conditions page is created with ACF custom gutenberg blocks with an wysiwyg editor and there is a link within the content of the wysiwyg editor the output of this block on the checkout page of woocommerce in the Terms and conditions hidden preview block (the one that opens within the checkout page when you click on the terms and conditions link of the checkbox) contains the ACF block code instead of valid html output.

    See image of generated html:

    While debugging I have found that when the function “wp_kses_post” (this function calls wp_kses()) that filters the post content is removed the html output is just fine. So wp_kses_post does something that breaks the wysiwyg content when there is a link in the text.

    The function is executed here:
    Woocommerce wc-template-functions.php line 875:

     * Output t&c page's content (if set). The page can be set from checkout settings.
     * @since 3.4.0
    function wc_terms_and_conditions_page_content() {
    	$terms_page_id = wc_terms_and_conditions_page_id();
    	if ( ! $terms_page_id ) {
    	$page = get_post( $terms_page_id );
    	if ( $page && 'publish' === $page->post_status && $page->post_content && ! has_shortcode( $page->post_content, 'woocommerce_checkout' ) ) {
    		echo '<div class="woocommerce-terms-and-conditions" style="display: none; max-height: 200px; overflow: auto;">' . wc_format_content( wp_kses_post( $page->post_content ) ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

    When there is no link in the wysiwyg the output is just fine.

    I cannot change this core woocommerce function without hacking into the plugin code. Has anyone an idea what I can do to fix this?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.