Decouple from WordPress databases by using repositories

A quick and easy way to decouple your code from WordPress logic, is by using repositories. Repositories are standardized ways to get and put data in a data store, usually databases. WordPress introduces a couple functions to interact with various database tables (get_post_meta(), get_option(), etc.) that are commonly used inside plugin and theme files, that are cumbersome to mock while testing. Repositories on the other hand are very easy to mock in unit tests. Continue reading Decouple from WordPress databases by using repositories

Class constructors should only setup the object

It’s common practice in the larger PHP world, but something the WordPress ecosystem has yet to catch up on. All too often, I see WordPress plugins and themes setup actions, filters and use other WordPress specific functions in class constructors. This leads to a class that is directly coupled to WordPress logic. Continue reading Class constructors should only setup the object

Gutenberg is progress

Over on the Mindsize blog, I have published my thoughts on why I think Gutenberg is just the progress WordPress needs:

A lot has been already said about Gutenberg and whether it should be included in WordPress core. How should it behave once it is included? Should it be the new editor for new sites only? Should it be an option that users can enable, or should it be on by default and give the option to disable it?

Mozart monkey patches WordPress’ lack of dependency management

A first proof of concept version of Mozart is now available for public testing. Mozart is a command line tool for wrapping PHP packages inside your own namespace. This is the least bad solution for solving most dependency management issues inside the WordPress ecosystem.

The fundamental lack of dependency management support inside the WordPress ecosystem has lead to a number of issues. Wrapping (third party) PHP packages inside your own namespace is something some developers already started doing on their own. Mozart simplifies and automates this process.

Say you want to use the Pimple package in your WordPress plugin. This package runs from the Pimple namespace. What Mozart does, is convert the files from the Pimple package, to use your own namespace, CoenJacobs\TestPlugin\Pimple for example. Your plugin can then use this package, inside your own namespace, so you always use the exact version you want.
Continue reading Mozart monkey patches WordPress’ lack of dependency management

Bundling libraries is not overhead, it’s a best practice

It’s been a while since I last posted something about the whole dependencies horror that I’m still trying to deal with in the WordPress ecosystem. Justin Sternberg’s post on the future of the CMB2 library got the discussion going again and soon after, we were at the dependencies discussion again.

It was mainly the discussion about overhead in bundling code that made me want to write a long reply, because I disagree with this quote:

What I hate is seeing someone use cmb2 when their own plugin is ten lines. But that’s them not understanding libraries and weight.

This post started as a comment on Justin’s blog post, but I figured it would make a lot more sense as a post on my own blog as it covers a lot more than Justin’s initial question about CMB2. Here goes… Continue reading Bundling libraries is not overhead, it’s a best practice

Video of my Love-Hate Relationship Between Composer and WordPress presentation

The video of my presentation about the Love-Hate Relationship Between Composer and WordPress at WordCamp Netherlands this year has been published on

You can find the slides on Speakerdeck. It was a great audience with some really good questions that have given me plenty of food for thought regarding the whole subject. It’s too much to cover in this post, so I’ll be going in some more detail in separate posts soon. I think there is a bright future for Composer in the WordPress ecosystem, there are some things that need to change first though.

Launching a product in a crowded WordPress market

Today I published the pre launch page for my side project Lapisense. In case you missed it, it’s a hosted activation and updates API for WordPress based products. If you don’t like running a plugin that does this for you, Lapisense might be a nice fit for your products.

I got a ton of great feedback already, but one of the questions really stood out to me. Why did I launch a product in such a crowded market? There are competitors out there, WP Updates and Freemius to name a couple. Both are really solid services already. But still, I wanted to explore this market, because I think there is more to achieve. Continue reading Launching a product in a crowded WordPress market

Explaining the WordPress plugins dependencies problem

There is a lot of confusion in the WordPress ecosystem when it comes to the issues around bundling dependencies. Peter Suhm has published a detailed post about this exact issue: A Warning About Using Composer With WordPress, where I have left the following (partial) comment:

So imagine both of us loading library x in our plugins, both requiring a version that’s incompatible with each other. No matter how well tested your plugin is, if I get a chance to load my autoloader before yours, I can load a version of the library that is not compatible with yours and your plugin will break (at least, the end user will see it like that and the horror of finding the culprit begins)…

This obviously is not a Composer issue, but related to the way WordPress loads its plugins. It’s also not a well known issue, since Composer isn’t used a lot in the WordPress ecosystem (yet!), especially not in distributed plugins. But as Composer becomes more used, more collisions like this will happen. Without a proper dependency management system in place, this is really hard to solve.

My WordPress Composer Installer proof of concept is as close to solving this issue as I’ve ever been. If there is anyone more experienced with the plugins installer in WordPress and maybe knows their way around Composer as well, I could use some help. 🙂

Solving dependency management in WordPress plugins

I’ve been working on a proof of concept for solving dependency management in WordPress plugins for a while now. It was in a private repository on GitHub, where I would invite some people in to work out the most obvious issues, while keeping it a bit on the down-low (this is a big change, potentially, after all).

Now it’s time though. The WordPress Composer Installer repository is now open to the public. Note that this is not more than a proof of concept, albeit it a working one. There are some hoops to jump through to get this working, but all these steps can be automated once I make this a fully featured plugin.

Recent blog posts like Ryan McCue’s take on solving dependencies and Gary Pendergast’s response to that are likely to fire this discussion up again. I will publish a more detailed post about why I think this is important, but I’m on a short vacation while I’m typing this and should probably be out enjoying sunny London. ☀️

Updating PHP is everyone’s responsibility

The number one remark I heard when I launched WPupdatePHP, is that users shouldn’t be bothered with this. In an ideal world, this is true, but in reality this isn’t going to stand for long. Allow me to explain why:

  • The core WordPress team can’t get every single hosting company to comply. I admire their intentions, but in reality this is not going to help everybody.
  • At the time of this writing, PHP 5.4 is actually already nearing its EOL date and we’re still figuring out how to make PHP 5.2 and 5.3 platforms go away…
  • The end user is one of our most important, but underestimated, assets in this battle. They have the strongest voice in this all.

Okay, that’s the tl;dr and now in a bit more detail: Continue reading Updating PHP is everyone’s responsibility