• r16n

    (@r16n)


    Hello,

    I am integrating the Consent Area Block into a page with Gutenberg blocks. I have my sections grouped using the group block. Whenever I accept the cookies, the content is not shown. It works perfectly fine when the block is at the root level of the block structure.

    Here’s a simple page with a grouped Consent Area Block to replicate the issue:

    <!-- wp:group {"layout":{"type":"constrained"}} -->
    <div class="wp-block-group"><!-- wp:complianz/consent-area {"blockId":"dt6uy","postId":161,"placeholderContent":"\u003cdiv class=\u0022cmplz-consent-block\u0022\u003e \n\u003cspan class=\u0022cmplz-consent-block-title\u0022\u003eWhat is HSTS HTTP Strict Transport Security Really Simple SSL\u003c/span\u003e\n\u003cp class=\u0022cmplz-consent-block-text\u0022\u003eBefore watching the video how to leverage SSL with HSTS, please accept YouTube cookies.\u003c/p\u003e\n\u003cdiv class=\u0022cmplz-consent-block-actions\u0022\u003e \n\u003cbutton class=\u0022cmplz-consent-block-button\u0022\u003eAccept\u003c/button\u003e \n\u003ca href=\u0022/cookie-policy\u0022 class=\u0022cmplz-consent-block-link\u0022\u003eWhich YouTube Cookies?\u003c/a\u003e\n\u003c/div\u003e\n\u003c/div\u003e","consentedContent":"\u003cp\u003eContent to show when cookies are accepted.\u003c/p\u003e"} /--></div>
    <!-- /wp:group -->

    I dove into the plugin’s code and saw that the issue is the cmplz_rest_consented_content function in rest-api/rest-api.php. If your replace the foreach on line 74 with this code

    $blockOutput = cmplz_rest_consented_content_find_block($blocks, $block_id);

    if ($blockOutput !== null) {
    $output = $blockOutput;
    }

    and add this new function

    function cmplz_rest_consented_content_find_block(array $blocks, string $block_id): string|null
    {
    foreach ($blocks as $block) {
    if ($block['blockName'] === 'complianz/consent-area' && $block['attrs']['blockId'] === $block_id) {
    return $block['attrs']['consentedContent'];
    }

    if (isset($block['innerBlocks']) && !empty($block['innerBlocks'])) {
    $output = cmplz_rest_consented_content_find_block($block['innerBlocks'], $block_id);

    if ($output !== null) {
    return $output;
    }
    }
    }

    return null;
    }

    it should work for nested groups as well.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Antonio Candela

    (@antoiub)

    Hi @r16n ,

    Thank you for reporting this.

    We have flagged the issue to our development team and opened an internal task. We will get back to you as soon as we have an update.

    Best regards,
    Antonio

    Thread Starter r16n

    (@r16n)

    Hello Antonio,

    Thanks for your response!

    I have a temporary fix in place. but please do let me know when the fix is implemented. Also, feel free to use (and modify) the code I provided.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.