General context: I have a plugin which implements a widget and I would like to make the widget into a shortcode.
The widget has many options some of them mutually exclusive, and it is never good UX to have widgets with 20 attributes in your content in any case.
The solution seems to be to use the customizer but how do I let it know about the shortcode's existence and where to store the settings?
One plugin that does a kind of virtual sidebar as a shortcode just ignores the customizer.
For the sake of the discussion we can assume only a small (less then 4) such shortcodes per content so that scale is not an issue.
Two directions I was considering but both have some "missing links"
Create virtual sidebars
- The problems are: (lesser) mapping a shortcode to a sidebar, and (bigger) preventing users from trying to drag widgets in and out of it.
Use postmeta to store the settings
- I don't know of anything that lets the customizer change postmeta.
Use an option to store the settings globally without making it an actual widget.
- This doesn't sound appetizing from a modularization POV.
Is there an option I missed or do I just fear too much of any of the listed options?
wp_query
. other plugins which implement a shortcode functionality are like this - wordpress.org/plugins/list-category-posts and you can look in the faq how ugly it can be. It is true that a better solution is to have dynamic creation of "in content" sidebars in core, but this is unlikely to happen before 2020.