• Resolved hupe13

    (@hupe13)


    I show in my documentation how to use the plugins shortcodes. I work with the default block editor and I get annoyed every time the block is rendered incorrectly, because I forgot to write it in [prismatic_code][/prismatic_code] tags. So I wrote a function that prevents this. Maybe you could include it in the plugin or put it in the FAQ.

    add_filter(
      'render_block',
      function ( $block_content, $block ) {
        if ( $block['blockName'] === 'prismatic/blocks' ) {
          if (strpos($block['innerHTML'], 'prismatic_code') === false) {
            return str_replace("[","[",$block['innerHTML']);
          }
        }
        return $block_content;
      },
      10,
      2
    );
    

    Edit: The replaced character should be & # 0 9 1 ; without spaces.

    • This topic was modified 6 months ago by hupe13. Reason: The second [ in str_replace should be [
    • This topic was modified 6 months ago by hupe13.
    • This topic was modified 6 months ago by hupe13.
Viewing 1 replies (of 1 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Thanks @hupe13, looks very useful. Will definitely add to readme.txt/docs, and maybe add to the plugin as well. I appreciate your sharing, thanks again.

Viewing 1 replies (of 1 total)
  • The topic ‘render block – nested shortcodes’ is closed to new replies.