php - Is it possible to nest wordpress shortcodes that are the same shortcode? -


I know that if they use do_shortcode wrapper, then it is possible to nest the shortcodes, however, codex says :

"Although the parser will fail if the shortcode macro is used to do another macro of the same name:"

Is there a way around this?

For example, if I have a shortcode to create a div:

  some content in [div] div [/ div]   

I want to be able to use:

[div] [div] a nested div [/ div] [/ div]

But this standard will fail with the do_shortcode wrapper.

I have a duplicate of the shortcode attached to _parent attached to my temporary outline name, but I have not created div_parent1, div_parent2 etc. only from the Nest 1 level depth ...

If you are writing a shortcut then there is a simple solution that you can write several shortcodes that call the same function. I have shortcodes to create HTML blocks such as divs, and many such names such as div, block1, block2 add_shortcode ('div', 'devondev_block'); Add_shortcode ('block', 'devondev_block'); Add_shortcode ('block2', 'devondev_block');

They all call the same function. They can be nested until you remember to use different short codes.

WordPress short code support is only suffixed with trying to parsing with regex, it is possible to do this type of parsing with a mixture of reggaeks, a finite state machine, and a stack. This approach can control nesting and can be very fast, especially when there are very few shortcodes every time I encounter it, I have to try.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -