I have a theme. It depends on a plugin. If you try to activate the theme and the plugin isn't installed, then I want to switch_theme() to some other (random**) theme in the search_theme_directories() list.

I can get the $template value from the key of the array returned by search_theme_directories(). But I can't seem to sort out how to get the $stylesheet.

Also, given this approach, what's the best way to check if a theme is child or a parent? Without getting into details I would prefer to pick parent theme as a default.

Perhaps there's a better way to do this? I would presume WP has something similar built in but I can seem to pin point that either. In short, I'm listenin' if you got ideas :)

Important

I was not able to tag this with: search_theme_directories(). That tag doesn't exist and I don't have the rep to add it. Could someone with some juice add it to the list of valid tags? Thanks.

Note: I'm first going to check for twentytwelve and twentyeleven and then if necessary pick one if they aren't around.

Thx @s_ha_dum but I don't think the first bit is going to work. For example, this is what works to switch to twentytwelve: switch_theme('twentytwelve','twentytwelve'); Notice how "stylesheet" ain't really so. I tried a number of different things, yours included and this is the only thing that work. As for get_the_theme(). If that gives me an object with theme details then that'll do. Cheers! Perhaps you can take another shot at the first bit?
–
Chief AlchemistApr 6 '13 at 23:13

1

What 'first bit' are you talking about? I dropped that code into a plugin file and it randomly switches themes on every page load as long I as keep reloading. I just re-pasted that second block from that plugin file just in case I had something wrong.
–
s_ha_dum♦Apr 6 '13 at 23:33

Oh. Sorry. Specifically, this: $stylesheet = content_url('/themes/'.$themes[$themename]['theme_file']); I tried that and WP didn't like it. switch_theme() doesn't want/need the folder structure. it wants a name. e.g. switch_theme('twentytwelve','twentytwelve'); codex.wordpress.org/Function_Reference/switch_theme. This is what had be confused and in search of a viable solution. Thanks again for your help.
–
Chief AlchemistApr 7 '13 at 12:52