Experimenting with WordPress Part 2 – Code Mapping

This post is the second part of a series called “Experimenting with WordPress”

What is WordPress really? Well, in terms of code, it’s simply a collection of ~3924 anonymous PHP functions, ~389 classes, and some polyfills. While there are some code patterns, the codebase is messy. Want an activity for the day? I challenge you to string together all of the PHP code necessary to boot WordPress from a single PHP file. The WordPress boot process is a labyrinth of rabbit holes, which will reveal hidden paths known only by the bravest of developers.

I get it. WordPress is old. Most of what PHP can do now didn’t exist when WordPress was created. But why do we tolerate bad looking code? Why can’t WordPress’ code look beautiful? Why can’t we remake WordPress? Those are the kinds of ideas I’m exploring with these experiments.

WordPress’s outdated naming conventions and testing out possible replacements with the help of AI.

In part 1 of this series, I created Minnow Transmuter as a way to port WordPress code into a proper PHP namespace. Most of that output code wasn’t organized in any particular way and ended up in a miscellaneous catch-all class. Well, with the help of AI and some aggressive updates to my mappings.yaml file, the output code is starting to feel like something a developer would enjoy working with.

Local development using WP-CLI with Minnow Bridge.

While organizing, I needed some way to visualize the codebase. So I added a mappings.html generator to Minnow Transmuter. You can see the current version of my experimentation here: https://minn.xyz/mappings.html. It has some basic interactivity. On hover you can see WordPress’ original class and function names. On click, it copies the new namespace, class and method. Each node is expandable which reveals nested classes and methods.

Names like screen, skin or walker are not very helpful when looking over the code. I’ve started to modernize them.

WordPress outdated namingModern naming equivalent
InsertAdd
ScreenAdmin\View
SkinView
WalkerBuilder

This project is just a concept. There isn’t a functional version fork of WordPress. I can somewhat interact with the fork using WP-CLI, however, that’s just enough to test out that the new PHP namespaces work and to confirm the original functions are still working. Getting the editor, customizer, wp-admin and other parts of the WordPress backend and frontend working would be a separate effort. I’m undecided how far I’ll pursue getting WordPress working vs. putting effort into showcasing how this could power something new. It would be amazing to somehow use a plugin like Gravity Forms outside of WordPress. From a project standpoint, here is a breakdown of how that might play out:

  • Minnow Transmuter – A command-line script that takes in WordPress core code and outputs organized, modern PHP code
  • Minnow Bridge – A potential rolling release fork of WordPress with modernized code (GPL licensed)
  • Minnow – A potential new MIT-licensed project with Vue.js and Vuetify to demo how a project can depend upon the Minnow Bridge to enable use of WordPress plugins.

Lots of ideas here and not really sure where all this will go. I will say that while digging deeper into the code itself, I have a greater appreciation for WordPress and all of the work that went into creating it. WordPress is a beast. It’s a pure joy to experiment with and imagine what a future WordPress might look like.

Austin Ginder
Austin Ginder