Roots Discourse

A Workflow for Modern WordPress Plugin Development


#1

Originally published at: https://roots.io/a-workflow-for-modern-wordpress-plugin-development/

:shamrock: Clover is a new project we’ve been working on since last summer. It is a goal of Roots to empower developers; this goal is infused into everything that we do and Clover project is no different. When looking for ways to contribute to the WordPress development community we found a need for a modern…


#2

Hell yeah, this is awesome. Looking forward to more.


#3

Thanks for do this. Very excited to get involved!


#4

I had previously worked on a WP plugin framework that was intended to support PHP5.3+ and thus be usable by most WP developers. I never really completed it, getting hung up on the ORM, which I wanted to be an abstraction over the combination of WP objects + meta as well as potentially backed by regular DB tables.

Anyway, the reason I bring this up is I did have one idea in there that I thought was pretty good. I had a Loader which would loop through all of the services registered with the application container. For any service that has a HasActions or HasFilters interface implemented, it would automatically bind those services methods to WordPress’s actions & filters. Long-term, I wanted to add support for managing said bindings via annotations, so you could declare a class, annotate the methods on the class with the relevant actions and filters, register it with the container, and it would automatically be bound to the WordPress filters, making it easy to implement object-oriented services without having random closures around and binding to actions in constructors or whatever, making it easier to test these services.

I bring this up cuz I always thought it would be a cool idea, but because I wanted to support PHP5.3, I couldn’t implement the annotations, as it would probably rely on doctrine/annotations and require some newer PHP features to make work. However, it might fit in quite well with the approach Acorn / Clover is taking.

Is this something you might be interested in adopting? I could extract the Loader & related interfaces and implement the annotations-based binding I was considering.


#5

Looks great! the next plugin I’ll make will be over Clover :slight_smile: That’s very soon…