osompress / simple-social-icons

Plugin: Simple Social Icons
62 stars 33 forks source link

Add ability to set per widget area defaults #87

Open dreamwhisper opened 5 years ago

dreamwhisper commented 5 years ago

We previously added the ability to set defaults for widget settings so themes could specify the expected settings rather than add custom CSS.

However, different widget areas may need different defaults depending on background color, space, etc.

This issue is to investigate the feasibility of adding defaults for different widget areas.

Preferably:

nickcernis commented 5 years ago

I spent some time with this and it doesn't seem possible with a pure-PHP/JS method using official WP APIs at the moment. The issue is that:

I can think of other ways to do this with JS, but they are hacks, rather than methods that use official APIs. We'd also need an alternative JS method for the Customizer.

I'll leave this open for now, though, in case others have new ideas or I think of something else.

mindctrl commented 5 years ago

I looked into this a bit too, and I agree with your assessment. There are ways to make it happen, but they do feel like hacks.

Under Appearance > Widgets, when you drop a widget into a widget area, an AJAX POST request runs. It contains the new widget's ID and sidebar location. We could tie into that and populate the form dynamically, and as you noted it would require something different in the Customizer.

I love the idea and think setting default values intelligently as @dreamwhisper describes would be a very nice user experience and set us apart from others in this area. I think it's worth exploring deeper as time allows.

nickcernis commented 5 years ago

Thanks for taking the time to look into this too @mindctrl, and for your notes. Leaving as needs-research for now in the hope we can revisit at some stage.