• Resolved tomrobertsuk

    (@tomrobertsuk)


    Hi Dilip,

    I’ve installed the plugin and added some FAQs, but I’m not seeing any JSON on the page. Is the plugin compatible with a full site editing theme?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Dilip Bheda

    (@dilipbheda)

    @tomrobertsuk I’ve checked with the FSE editor and it seems working fine, You can check with https://playground.wordpress.net/

    Thanks

    Hi,

    \Faq_Block_For_Gutenberg::gutenberg_faq_block_parse_blocks uses parse_blocks() function, which returns an array of first-level blocks. The fact is that each block may contain nested block(s) where FAQ may reside.

    So, to parse the entire post content, I think you need to make this function recursive.
    Something like that:

    private function gutenberg_faq_block_parse_blocks($blocks = null) {
    global $post;
    $block_data = array();

    if( empty($blocks) && $post ){
    $blocks = isset( $post->post_content ) ? parse_blocks( $post->post_content ) : array();
    }

    if( !empty($blocks) ){
    foreach( $blocks as $block ){
    if( 'faq-block-for-gutenberg/faq' === $block['blockName'] ){
    $block_data[] = $block;
    continue;
    }

    // Search in nested blocks
    if( !empty($block['innerBlocks']) ) {
    $block_data = array_merge( $block_data, $this->gutenberg_faq_block_parse_blocks($block['innerBlocks']) );
    }
    }
    }
    return $block_data;
    }
    Plugin Author Dilip Bheda

    (@dilipbheda)

    @cyrilbatillat Thank you!

    I’ve resolved the schema JSON issue with nested blocks. Please check with the latest plugin release (v2.7) and let me know if you encounter any issues.

    I’m going to mark this ticket as resolved. Feel free to open a new support ticket if you have any issues or suggestions.

    cc @tomrobertsuk

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.