Get list of all registered sidebars

I am registering sidebars automatically for each category (a separate widget space per category). The technique I’m using is here.

In the admin side I have an options page where I need to display a dropdown of all registered sidebars… Is there are way to dynamically get this list of registered sidebars? since they’re being registered in functions.php I assume they’re in memory, not in the database.

I could keep track of the sidebars I register in some global variable, but just in case plugins register their own sidebars, I’d like to account for them too.

I’ll dig through the core if I have to, but thought someone might know off-hand:)

Thanks

1

Hmm… I’m not sure if this is the best way to do it but it’s simple:

I looked in register_sidebar() and found that new sidebars are simply tacked onto an array:$wp_registered_sidebars

And I guess that’s that. If they ever change the name of the variable, I guess I’d be screwed.

Leave a Comment