I've tried finding something on this but had no luck.
What I'm wondering is how do I auto-enable needed core plugins for a theme and if this is considered a bad idea or not?
Looking at the code in admin-plugins.php, it appears I can set the value of the plugin using `setOption('zp_plugin_name', THEME_PLUGIN + 1);`, but I'm willing to bet that'd be hackish and not the way to do it.
It also doesn't give the user the ability to turn it off if they do indeed decide they don't want that functionality and I'm going to also guess that's bad practice according to ZenPhoto standards.
Comments
`setOption('zp_plugin_', , false);`
<plugin priority> would eiter be the value set by the plugin for `$plugin_is_filter` or `THEME_PLUGIN | 1` (which is the default if the plugin does not specify.)
This would need to be done at the head of each of your script files which need the plugin as it last only the duration of the page load. See, for instance, functions.php of the Effervescece+ theme which does this for the print_album_menu plugin.
Here's two possibilities I see:
The disadvantage to this method is that it would add extra (unnecessary) rows to the database when there is already entries for them and secondly I'd have to do additional testing to see if the plugin is enabled on the plugins page or completely ignore those settings.
Still, I would not recommend that as I suspect it would be confusing to people to have theme options to enable plugins.
Instead just make a theme option to control the use of the transient option setting mentioned above. Or maybe better still, just a note in your theme description that it will use the plugin if its enabled.
The reason I wanted to do it on the theme options page was because I'm very new to it and dove into ZenPhoto looking for a Flickr clone script. I wanted a simple gallery that was easy to navigate and wasn't quite so album-oriented, but just had a simple stream of photos with the option for albums.
I stumbled across the Flickrish theme, but once I installed it, it came up with a few errors and it took me a while to figure out they were plugin errors because the required plugins weren't enabled. Since Flickrish was close, but still not quite what I wanted (it still doesn't have the photo stream), I decided I'd spend a few days rewriting it and making it do what I wanted to begin with, which ended up being a HUGE undertaking being my first time using ZenPhoto.
So...
with all of that being said, if a theme has a few to several plugins it can utilize and yet I have to keep flipping back and forth between where it says what plugins it needs and then the plugin screen to enable it, it becomes a tedious task. It made much better since to just allow the user to activate the plugins from the theme's options page so there's no fishing around trying to get it to all work. All of the needed plugins are nicely grouped together where they can be set there or on the plugin page, whichever suits the user.
I did end up choosing the least recommended method simply for the reason the plugin can be set on/off via either the plugin page OR the theme's option page, whichever is most convenient to the user. For a newbie like me, it would've been a WHOLE lot easier if they had been on the theme's option page to begin with since I didn't care to spend a lot of time exploring the admin panel or trying to figure out how it all works.
I'd love to get your feedback on the code once I get enough done to make a commit to GitHub on the revised theme if you're interested.
I really appreciate your help too! Couldn't have gotten this far without it!
The key is whether it "uses" them or "needs" them. If it only uses them (that is it works perfectly properly without them) then you will only confuse people by allowing them to enable the plugin on the theme. If it "needs" them then the user should have to do nothing to get the theme to work--thus the theme shoud set the plugin to enabled without prompt. But of course, it should do that temporarily so as not to impact other themes.