The late developer blog at code.moussaclarke.co.uk
@moussaclarke on socials
Modern WordPress 🚀
Not an oxymoron
Press Space for next page
1
Who am I?
Senior Developer at Sanders Web Works
Music, code, beer
The late developer blog at code.moussaclarke.co.uk
@moussaclarke on socials
2
WordPress rocks 🤘
3
Rocks 🤘
It’s popular!
It’s got comprehensive and well-maintained documentation
Erm… it’s popular?
4
WordPress sucks 💩
5
Sucks 💩
Clunky DX
Composer? PSR-4? Anyone? Bueller?
So… many… crap… plugins
Global namespaces ftw
jQuery!
Also React, but probably not the style you’re used to
How in Cthulhu’s name do I use a frontend build tool?
6
Sucks 💩
Bad procedural patterns
Weird antiquated php 4 syntax
Inconsistent and unmaintainable spaghetti awfulness
“Template” soup - ok, boomer
Almost everything is globally scoped. Good luck with that
Functions with dozens of parameters.
functions.php with thousands of lines and meaningless function names
Like, really hard to test
7
Sucks 💩
Types? Never heard of them.
Or maybe they exist, but they are wrong.
Or maybe they are correct, but they make no sense
Or they are all “mixed” and therefore useless
Side effects everywhere - echo everything most of the time, but sometimes not. You have to guess, because there is no reliable typing so static analysis won’t help you.
No dependency injection
Hooks, filters and actions - a mess of race conditions
And don’t even get us started on the loop, which is just… wat?
8
Why not just use Laravel/Symfony/Slim etc? 🌈
9
Because clients like WordPress 🫂
They know it
Its ubiquity and familiarity makes it the de facto CMS.
It’s not just popular, it’s extremely popular, a veritable behemoth. It powers half the internet. And yes that goes for enterprise level customers too.
No one cares about your cool framework, just ship it already
10
Budget 💸
A flexible ready made admin system. Yes you could build one out in e.g. Orchid or Sonata or whatever and it’s going to be way nicer and more bespoke, but it’s going to take you longer at least initially and you still won’t have feature parity.
Also those crappy plugins we’ve mentioned actually make it super quick to get features out the door. Online shop? No problem, here’s WooCommerce. Admin fields? Sure, ACF to the rescue. Frontend forms? Spin up Contact Form 7 or Formidable.
11
Legacy Projects 👴
Maybe you inherited something.
Maybe you built it before you knew any better.
Yes, these projects have possibly outgrown the platform or shouldn’t have been built with WordPress in the first place, but they still need maintaining and refactoring and new features added, and face it, you’re never going to be doing that great big rebuild in the sky.
12
Sometimes you have to use WordPress 😭
13
But… you can still have nice things 🥂
You can get all the maintainable patterns and friendly DX you’re used to from saner frameworks.
Routing, models, PSR-7/PSR-15 Request/Response, Job Queues, view templates, DI Container, ORM, DB Migrations, the lot…
In fact, there is a whole thriving open source ecosystem around this concept.
14
The ecosystem 🌍
WPackagist
Frameworks
And our very own contender… Forme
15
WPackagist 📦
A packagist repository that mirrors all publicly available plugins and themes.
composer require and off you go.
For private PHP repos, we use Satis.
16
Frameworks 🏗️
Will provide at the very least:
A project installation boilerplate
Composer & PSR-4
.env alongside or instead of wp-config
Database Migrations
DI Container
Custom Routing & HTTP Middleware Stack
Models - usually Eloquent at least abstracting base WordPress Posts/Pages and Users, but also Custom Posts, Meta, Menus, Shortcodes, etc.
View templating - Blade, Twig, or Plates
Controllers plus views instead of "templates"
Frontend build tools (e.g., Webpack/Vite) and some way of referencing built frontend assets
17
Frameworks 🏗️
Some also offer:
Nicer patterns for dealing with WP entities and concepts
Code generation & dev tools
Job Queues
Deployment frontend build system via e.g., lerna.js
Testing setup (e.g., Pest + BrainMonkey)
A way to package your plugin or theme for the WP directory
18
Third party plugins and libraries
19
Directory Structure
20
Example Controller
21
Yay tests!
Caveat: real-world integration tests still hard because of plugins