chrisguitarguy / WP-Plugin-Directories

Allows you to add additional plugin directories to WordPress.
MIT License
23 stars 8 forks source link

Make it possible to use as a library inside a Theme #4

Closed julien-c closed 12 years ago

julien-c commented 12 years ago

I think this would be most useful as a library inside a Theme, not as a plugin (see my use case on WPSE: http://wordpress.stackexchange.com/questions/46364/plugin-or-theme-containing-its-own-plugins)

However, it currently doesn't work because plugins_loaded (the hook used to add more plugins) is fired before the theme is even loaded.

Is there a way to make it work by plugging into another hook than plugins_loaded?

Thanks!

chrisguitarguy commented 12 years ago

You could change plugins_loaded for after_setup_theme. The two times this hooks into plugins_loaded could be switched without many consequences.

The question is whether it should! If you're bundling plugins with your theme, I'd suggest not using this plugin in its entirety. Just add a view to the plugin list table that displays the plugins added and included by your theme. You don't need your users to turn them on/off right? And this doesn't updates for plugins found in other directories.

julien-c commented 12 years ago

I actually do need my users to turn them on/off (all the plugins are off by default for simplicity's sake).

I'll try to include the plugins on another later hook then. I guess some plugin functionality might get broken though, right?

Thanks!

chrisguitarguy commented 12 years ago

I'm not sure if any functionality of this would get broken from moving plugins to loading later. But, honestly, your one use case isn't enough incentive to change the code.

I think what you're trying to do is more akin to adding and removing features from a theme based on user options -- which can more easily be done from an options page.

julien-c commented 12 years ago

Except that I will encourage my users to download plugins after installing the theme (not all plugins will be included in the theme) and install them into my theme's plugins subfolder -- which is why I think a plugin dir. would make more sense than options.

I'll be following the evolution of this plugin anyways, thanks!

chrisguitarguy commented 12 years ago

Ah, gotcha. That makes sense. I'd think I'd just take the approach of creating those integrations and mentioning then letting the users install plugins if they want. This is still a bit to hackish to work well for that use case -- the core would need to be changed to make it happen more nicely.