Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nesting code snippet shortcodes within code snippet shortcodes #198

Open
sheabunge opened this issue Dec 5, 2024 · 2 comments · Fixed by #213
Open

Allow nesting code snippet shortcodes within code snippet shortcodes #198

sheabunge opened this issue Dec 5, 2024 · 2 comments · Fixed by #213
Assignees

Comments

@sheabunge
Copy link
Member

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/

@lightbulbman
Copy link
Contributor

lightbulbman commented Jan 19, 2025

@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

@lightbulbman lightbulbman self-assigned this Jan 19, 2025
@lightbulbman lightbulbman linked a pull request Jan 20, 2025 that will close this issue
@sheabunge sheabunge reopened this Jan 26, 2025
@sheabunge
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants