codesnippetspro/code-snippets

Allow nesting code snippet shortcodes within code snippet shortcodes

Opened this issue · 2 comments

Is your feature request related to a problem? Please describe

There is currently no way to use the [code_snippet] shortcode within a HTML snippet, even with PHP and 'Evaluate additional shortcode tags' enabled.

Describe the solution you'd like

Create a HTML snippet with the following code:

[code_snippet id=42 php shortcodes]

Create a second HTML snippet that references this first snippet:

<div> [code_snippet id=1 php shortcodes] </div>

The second snippet should render the content of the first by evaluating the shortcode.

Describe alternatives you've considered

No response

Additional context

Originally raised by daisensou here: https://wordpress.org/support/topic/nesting-a-shortcode-inside-a-html-snippet/

@sheabunge - I have developed a working model for this with some small changes to the front-end class --- this now works if you have 2 html snippets like this:

Code Snippet ID = 5
<h1>TITLE</h1> [code_snippet id=6 name="Subheading"]

Code Snippet ID = 6
<h2>SUBTITLE</h2>

And you place the shortcode for snippet with ID = 5 on a page like this:

[code_snippet id=5 name="Heading" shortcodes]

The the output will be:

<h1>TITLE</h1>
<h2>SUBTITLE</h2>

tbh - I wasn't sure what exactly the 'shortcodes' attribute did or how it worked so have modified the code that handles this - can rework if this is wrong

p.s. Apologies that most of these fixes/changes are being done in a branch created for one feature/issue - I thought it would be easier this way then creating multiple branches

Unfortunately, it seems like this is pretty buggy. We'll need to revisit and release a patch.