I’d like to develop a setting/control for Customizer that allows dynamically to add fields. The typical example would be the possibility to add an unlimited number of slides to an slider in a Theme. There would be a button in the Customizer setting called “Add new slide” that allows to add a new slide field.
For the sake of the responses, let’s make it easy: Just a text field per row. So each time we click on a “Add new row” button, a new text field is generated.
The problem is how to handle dynamically those settings? How to use the WP_Customize_Control to_json function and how to get that Mustache template and duplicate it every time we click on the “Add new” button? I have a very good background on PHP and a medium level on JS so I can understand advanced topics.
You could use or take a reference from Kirki. It is a framework that allow to add customizer controls with less code.
Take a look to Kirki::Repeater_Control here.
This is awesome,have a look it’s the best