I'm creating some shortcodes that will build an accordion. I need the following:
[accordion]
[accordion-item title="Trigger Text"]Panel Content[/accordion-item]
[/accordion]
I want to create a button in TinyMCE to make it easier for the client to build the accordion as the shortcode syntax will be too confusing for them. From what I can tell, there is no way to create a pop-up that will allow for repeatable items (each accordion will have varying numbers of items) within the TinyMCE pop-up, so I was then thinking of just having a button that will allow them to do an accordion item. This means I need someone of prepending and appending the [accordion] wrapper around it.
Is there a way I can find the first instance of a shortcode and put the necessary HTML code before it and likewise, after the last instance but the closing tag after the last time the [accordion-item] shortcode is used?
My only other idea was having the client indicate if the panel they are adding is the first or last within the accordion group. This is fine, to begin with, but could confuse them if they return and add more items at a later date.
I'd prefer to do this accordion as custom - I do not want to use an already existing plugin as I don't want to have to rely on updates etc. from plugin developers.
Of course, I am open to any other suggestion in being able to make this process easy for my client while still allowing the use of my accordion markup/script.
Any advice would be greatly appreciated.
Thanks, Jess