Categories
Web Development WordPress

Do we want or need the features in theme.json?

I have been a supporter of WordPress for years, and will continue to support it’s mission to democratize publishing. So many of the ideas WordPress has introduced over the years have been amazing, but the theme.json beyond use as a description file was almost a good idea with much to be desired in the execution. As is done in Twenty twentyfour at the time of writing this, we should stick to using functions.php for all code and only have the theme.json file be there to give metadata about the theme. I am not suggesting we abandon the idea of a theme.json or roll it back entirely, I am just suggesting we do not try to use it to do things like add styles or load scripts. I think Sam Hermes gets this just right in his article at https://samhermes.com/posts/slowly-backing-away-from-theme-json .

The theme.json file is a cool idea, but the execution is not very cool. Having the file allows you to convey theme information which is useful but it also allows us to edit a lot of features of WordPress that most people do not need. It takes away features that people do need by hiding them or making them impossible. The process introduced by theme.json is also potentially alienating long-time users who are used to the way things already worked in “classic” WordPress, and the use of the file is not bringing in new users. “Did you hear that WordPress lets you just write JSON to edit the theme now? Sign me up!” Obviously no one who is not a developer ever said that so the feature that is supposed to attract developers with a more efficient workflow just ends up alienating them because the things they knew and loved about WordPress are gone or different now. The feature ends up attracting no one new and alienates the old user base so it is really a loser of a feature all around.

I suggest we only use the theme.json for limited metadata about the theme, and we go back to using functions.php for the important theme configuration. I want to emphasize that I am not saying to get rid of the theme file, I am just suggesting we make sure it is not important and go back to using the functions.php file for everything code.

At work, I work on several WordPress classic sites and one WordPress site that uses a theme.json. The theme.json site is not bad, and from the front-end user view it is no different from any other site. On the admin side of the site it is a different story, it does have a few differences which I find ok, but it also has a few differences which I do not find ok. Thankfully, we can and did use a supplementary functions.php with the theme.json file.

It sounds efficient to have your different kinds of code and theme functionality simplified by being set with one language and all sent from one place by json which is what the theme.json file does. In reality of course, if someone is editing a json file and writing code then they are a developer. This feature is meant to attract developers but does not. A random non-developer is never going to write a code file in the filesystem of their web server, and that should not happen. The WordPress platform out of the box with plugins allows users to make semi-complex sites without any assistance already, but that is kind of the limit of what a normal person can make without hiring some help.

This coming on the heels of the even worse decision to remove ‘Menus’ from the dashboard, stop using the header.php file as well as the footer.php. Why are we changing WordPress so drastically when it was the market leader for CMSs by far in a way that makes it more similar to it’s failing “competition”? I put that word in quotes because technically they were competition but they were all so far behind.

Can a regular person wire their house with electricity? Maybe in a few cases but the answer is generally no so they hire a specialist to do it. Who is WordPress core making this theme editing process better for? Some random, unassisted person is not going to write code, so why are we making it easier for them? The users the theme.json is made to help will never use it. Let’s pivot away from using theme.json to do theme code adjustments in favor of using it to store metadata (like theme headers and possibly a simplified way of adding fonts to the theme) and use the functions.php file to add/modify the code.