I'm developing a wordpress plugin that needs to be able to detect whether the currently active theme has widget-capable sidebars, so that it knows whether it can add widgets or not. So, how do I detect whether the current theme is widget-aware?
2 Answers
You'll be glad to hear there's a couple of variables which WP uses:
$wp_registered_sidebars and $wp_registered_widgets
Then, as per wp-admin/widgets.php:
$sidebars = array_keys($wp_registered_sidebars);
Don't forget, WordPress does this itself - if there are no widget-read sidebars in a theme, the widgets.php page tells you so (if you look at wp-admin/widgets.php in the core, you'll see how, but those 2 variables are the basis of it)
There is no good way without installing the theme and trying it to determine if the sidebars and widgets REALLY work. I keep a spare domain just for testing themes and widgets in WordPress. WordPress is a wonderful tool (I run at least a dozen domains with it), but some themes are flaky.
Another thing to test is whether the widgets appear correctly when you put them in a specific sidebar. I've found several themes that copy the widget data from the left sidebar to the right side bar and visa-versa.
The default sidebars (with no widgets added) are nothing like the side bars that you get when you start moving widgets around.
Welcome to the wonderful world of experimental Computer Science.