maddisondesigns / customizer-custom-controls

WordPress Customizer Custom Controls
403 stars 120 forks source link

How would I allow the Repeater Field to create a new theme_mod for each row? #1

Closed redlagoon closed 6 years ago

redlagoon commented 6 years ago

First, since this is the first issue ever -

Amazing work. Truly shows you understand the inner workings of WordPress. That repeater field is killer!

But it has a tiny issue which makes it, in my case, unusable.

I'd like for it to spit out an array, I know that each customizer option is stored within a theme_mod but do you have any idea how to create a dynamic array for this theme_mod instead of just a string?

It should be an associative array, such as:

$repeat_control_values = [
    'link1' => 'link.com',
    'link2' => 'link2.com'
]

Thank you and amazing work, once again.

maddisondesigns commented 6 years ago

Thanks for the kind words.

The only issue with having it product an associative array like that is that you'd also have to pass through a list of data that your control is saving/collecting. Although with that said, it could be tweaked to just assume it's being used for social platform urls. I did try to create the control so that it was sort of generic though, so that it could be used collect any type of data (with minimal tweaking).

Please tell my if I'm wrong, but I'm presuming that you want to use the control in a similar manner to the example that I mentioned (i.e. save a list social urls). I'm doing this exact thing in my latest theme that I released on .org.

I would suggest downloading my latest theme and check out out how I've used it - https://wordpress.org/themes/ephemeris/

My Ephemeris theme makes use of my Sortable Repeater to display a row of social icons. You can view a demo of the theme here - http://demo.skyrocketthemes.com/ephemeris/

If you have a look around line 1415 in functions.php, you can see how I generate the unordered list of social icons using the urls saved in the Customizer.

https://github.com/maddisondesigns/ephemeris/blob/master/functions.php#L1415

Let me know if this helps sort out your concerns.

maddisondesigns commented 6 years ago

I'm going to assume my solution I mentioned above works for you, and close this issue. Feel free to open another or just reply here if you've still got issues. Thanks :-)