WordPress.org

Ready to get started?Download WordPress

Ideas

Subplugins : ship several plugins into one

  1. Fab1en
    Member

    Sometime, a plugin code grows to a point where you need to split functionalities into smaller parts. Then users can choose to activate all the parts, or just the ones they need.

    For example, WPML provide a whole bunch of plugins that aims to translate different parts of your site: Pages and Posts, Media, Strings, Professional Translation Management ... But those plugins depends on each other. Another example is WordPress SEO by Yoast. There is the main SEO plugin, a Video SEO companion plugin and a Local SEO plugin. Video and Local SEO both need the main SEO plugin to work.

    The idea is to provide a mechanism to ship several sub-plugins into one main plugin. The main plugin would have the task to see if subplugins are installed, to verify dependencies and upgrades availability and to load (with require) the subplugin php files if they are activated. Updating a subplugin should not be possible without updating the main one. This would allow plugins author to easily avoid loading a big amount of php files if the user only use a small part of the plugin. Subplugins code could be located in a subdirectory of the main plugin, but still appear in the Plugin management screen.

    That would be different from Child Plugin (http://wordpress.org/ideas/topic/child-plugins) as the main plugin should be aware of the subplugins existence.

    I tried to implement a very simple version of this idea in my Media Helpers plugin (http://wordpress.org/plugins/media-helpers/). This plugin is a collection of small scripts that enhance the Media experience. Each script can be enabled independently and it's file is loaded by the main plugin only if needed. The subplugins files has been written as if they were a standalone plugin.

    Posted: 7 months ago #
  2. Ipstenu (Mika Epstein)
    Administrator

    How is this any different from having a plugin with checkboxes to activate features? Or a plugin that checks if another plugin is active before activating?

    I would say that having separate plugins entirely is better, since I can install what I need, and not have unused code sitting on my server.

    Adding extra complexity to upgrading for things we can already do doesn't seem to lend enough benefits.

    Posted: 7 months ago #
  3. Fab1en
    Member

    I think this is as different as reinventing the wheel for each plugin author that needs this feature. Providing a well written code base, a common interface and a common behavior could improve a lot the plugin experience.

    Some authors decided to manage the whole subplugins versions and activation within their own main plugin (easyReservations for example). But all this code is a one shot and cannot be reused. What a coding energy waste!

    WordPress core could provide simple helping features for plugin authors such as :

    * Having a declaration in the plugin header of the other plugins it relies on, and use this indication in the plugin activation page to 1) group plugins and 2) forbid activation of subplugins if the main one is not active.

    ( OR )

    * Provide a simple Plugin API to declare independent features inside a plugin that can be activated separately, and provide a simple UI in the plugin activation page (with a auto hiding div ?) where features are described and can be activated/deactivated.

    I agree that the upgrading part could be more tricky.

    Posted: 7 months ago #
  4. Ipstenu (Mika Epstein)
    Administrator

    Having a declaration in the plugin header of the other plugins it relies on, and use this indication in the plugin activation page to 1) group plugins and 2) forbid activation of subplugins if the main one is not active.

    Item #2 is already done.

    See is_plugin_active - http://codex.wordpress.org/Function_Reference/is_plugin_active - So you can check if a plugin is installed and active, before allowing your to activate.

    Posted: 7 months ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    0 Votes
  • Status

    Sorry, not right now