The debate over plugin dependency has been around WordPress for years. I strongly believe that WordPress core needs a simple plugin dependency API for a healthier WordPress ecosystem.
Building plugin dependency into core does more than make something already possible easier. It encourages a mindset for developers to rely on existing, reliable code for use in their own plugins, rather than reinventing the wheel for every plugin they write. It also offers opportunity for end users to get more advanced, reliable solutions for their websites.
There is precedent in WordPress for such a feature enhancement. The Taxonomy schema we know today was introduced in WordPress 2.3, but it wasn't until 2.8 that custom taxonomies became commonplace; because WordPress made it much simpler to register taxonomies by enabling default metaboxes and admin view handling upon registration. The change made it much simpler for plugin authors and even end users to register and use their own taxonomies, as well as ensured more consistent and reliable code.
Today, there are dozens of examples of functionality that is repeated over and over again in hundreds or even thousands of plugins. People have written plugins for simpler settings page registration, metabox creation, admin column management, frontend utility shortcodes, form creation, login widgets, role management, and a myriad of others. Many of these plugins are extremely useful beyond cases where they act alone.
In other words, it would be great if a plugin developer could use another developer's quality, existing code in their plugins versus re-doing the same thing as part of their plugin, potentially not as well.
As a web developer, one of my functions when consulting a client hardly requires code. I'm often asked to marry functionality from various plugins to bring them together to establish desired functionality for a website. This is why I've renamed what we offer to our clients as “modules” instead of plugins.
I consider a module a whole piece of functionality. WordPress eCommerce is a module. It typically requires more than a plugin like Easy Digital Downloads or WooCommerce alone to create a client's desired functionality. Membership is a module. I may need a combination of several plugins to achieve the desired functionality.
While I'm glad I can offer this service, it's particularly innefficient. As WordPress “experts” we know which plugins to use and how to use them. We can dance this dance of marrying plugins, with a mix of our own code, to achieve desired functionality. But our knowledge to do so isn't common, and definitely isn't widespread. Moreover, it's currently difficult to implement at greater than a 1:1 level. Meaning, if I do it on one site, I pretty much have to repeat the same steps on the next.
But what if I could do it differently?
With dependency, I could create a packaged solution that offers advanced functionality without reinventing the wheel, and I could make these solutions scalable.
I imagine such a feature to work similarly to what Scribu's prototype, the Plugin Dependency plugin (super meta, right?). A simple
Depends: plugin1, plugin2 line in the comment block of the main plugin could act as a module umbrella. Now, developers can marry multiple plugins to create modules of full-featured functionality, on a 1:many scale.
This can also help reduce “mega plugins”, limit bloat, and promote DRY principles. Finally, one of my favorite bits, is that large plugins can reduce themselves into smaller useful pieces so people can only use the parts they want, and simultaneously others can use the entire thing if it's their desire (Jetpack comes to mind as a perfect example). And they can do so while still allowing users to just intall “one” plugin and get all of the functionality available.
Why this is related to, but different than the extensions model
What I'm proposing is different, but still related, to the well known extensions model. Previously mentioned plugins WooCommerce and Easy Digital Downloads are fantastic examples of the extensions model.
But what I want is to go a step beyond. I love that these reduce bloat and increase functionality with extensions. But, as an example, let's say I want to create a Wholesale functionality for eCommerce. I could then create a “Wholesale” plugin that requires WooCommerce and other previously existing extensions that help me achieve the functionality I need. And of course I'd have the code necessary to top off what I want to do.
But why wouldn't I take advantage of already existing, stable, time tested plugins for 80% of the functionality of my new plugin?
Not limited to plugins
Of course, depency isn't just limited to plugins. In fact, its biggest impact could be with themes. We all know about the bloat of themes that try to pack a world of functionality into themselves; in fact, I just ranted about one the other day. With dependency, themes could reliably use plugins that achieve the necessary functionality they are trying to showcase, while maintaining their own footprint as a primarily presentation layer.
With a dependency standard in place, end users can really win. If they want to change themes, it becomes no problem; because the functionality is in the plugins and not the themes. And theme providers win too, because they can still offer themes that present a solution and not just a template and coat of paint.
On the right track
Otto Wood has written a post on how to achieve dependency in plugins, and Thomas Griffin has a very full featured class to do so. But these tools are still primarily beneficial to developers who want to make their life as a client services provider easier. And in Otto's post comments, he argues that this functionality should not be in core. I disagree.
The concept of plugin dependency will have a hard time getting real user trust, in my opinion, until such functionality is backed by WordPress core. And it certainly will be hard to make mainstream if it's always a standalone class to be implemented each and every time by a developer.
Custom content types and custom taxonomies were possible before WordPress 2.8 and WordPress 3.0, respectively. But we all know how their enhanced support in core (and a true API for CPTs) exploded the acceptance of their use in real life.
If WordPress itself is willing to support the idea of plugin dependency, I think it can positively affect the long term quality and sustainability of plugins similar to the way custom post types and taxonomies have for establishing WordPress as a full fledged CMS.
Plugin dependency could establish a trajectory for WordPress to be a better application framework.