The author said:
My dislike of WordPress is no secret. I look down on its mess of a code base, and advise anyone with any technical knowhow whatsoever against using it.
Is the situation that dire? Is the WordPress core code really so atrocious that you should steer clear altogether and use something else for your project? In this article I’ll take a look at the issue and help pour some clarity on it.
- What Is Bad Code?
- Coders Don’t Matter
- Users Don’t Care
- Coders Aren’t Affected
- Is It Possible to Write Good Code?
What Is Bad Code?
I think the fundamental issue is that noone really says what bad and messy code is. On paper something like “messy code” sounds horrible, but does a casual reader know what that means? More importantly, does she/he care?
As always, there is a little more to it than that. There are a few properties that could make code “bad”, here are just a few:
- Unoptimized code which performs slowly compared to optimized code
- Mixing coding styles within a project
- Spaghetti code which can only be understood by the author
- Unextendable that doesn’t play nice with others
WordPress is indeed guilty of one and a half of these. The coding style is all over the place, that’s for sure. Function names are inconsistent, some modules use a strict object oriented approach, some modules use procedural code, many files don’t use WordPress’ own style guide, – just a few issues.
This means that WordPress uses spaghetti code somewhat, but apart from being annoying it’s not a problem because literally thousands upon thousands understand it since it is such a widely used product.
So is WordPress badly coded? Yes, in the same way as the International Space Station uses bad laptops. Both statements are objectively true but there’s a bit more going on behind the scenes.
The real question is, does this matter?
Coders Don’t Matter
At every WordCamp I go to I get asked the question: would it be great if WordPress switched to a fully OOP approach. The programmer in me says, yes of course, it would be the happiest day in my life. The rational person in me (definitely not the programmer) preaches caution since this move would directly contradict everything WordPress stands for.
As programmers we have to remember that WordPress – at the end of the day – is for the users, not for us. You may think that spending 100+ hours on a project is a lot but the person who uses your work may spend 8 hours a day using it which would amount to 3,000+ hours a year, and that’s only if your work is used by a single user.
Users Don’t Care
Users really don’t care about anything related to code. They want something that is user friendly, fast and secure. WordPress does very well on all three. You can argue that badly coded plugins can ruin WordPress’ speed and safety but that’s like saying my Volvo wasn’t safe because I got injured driving 180 miles an hour into a wall.
Coder’s Aren’t Affected
The vast majority of people who work with WordPress aren’t affected by this issue, or at least don’t have to be. There is simply no situation where you would need to touch core code for a project. This means that you won’t be affected by the messiness of the core code at all.
The only argument coders could have against WordPress is that it doesn’t follow an MVC (model-view-controller) architecture. This is a completely valid criticism, but it’s not like MVC is the only way to write clean code.
In fact, you can use a full on object-oriented approach in plugins and even use and MVC-like structure if you prefer. The real problem is with themes which are built in a way that you can’t just inject MVC principles.
That said, themes follow strict guidelines and are well structured, despite not being MVC. This boils down to a common vein in every theme which makes it easy to work with them if you know what you’re doing.
Is It Possible to Write Good Code?
The issue is not wether WordPress core code is good or bad. WordPress core code is somewhat of a mess, but it is still good code. This doesn’t mean it couldn’t be vastly improved but for the purposes, it serves it is great.
The issue is: is it possible to write good code with WordPress. The answer is a resounding yes. As I mentioned earlier, plugins are free-form so you can do whatever you like there, including OOP.
I do also want to stress that OOP is not a cure-all. For simple plugins, a well laid out procedural approach may be a lot clearer.
Themes do mix presentation with logic, this is undoubtedly a bad practice. However, the guidelines for themes are well laid out and with some planning a structuring you can write a logical and easy to follow theme.
With the advent of the WordPress API all other criticisms go down the drain because you can pretty much use the data in the database anywhere. You could use Laravel for everything and pull in the data via the WordPress API.
Summary
So at the end of the day, is WordPress code a mess? Yes, some of it is. Some plugins and themes really do contain bad code and hinders the community as a whole. Like any other project WordPress is not perfect. Just like any other project, I agree that WordPress should not be used for everything.
However, not using WordPress because “the code is a mess” is – to put it plainly – a dumb and shortsighted reason. While the core code is a bit of a jumble it is fast and secure. Any code written on top of that to extend the system can be written well.
The trick is to employ professionals, use trustworthy and high-quality products and maintain your website properly. And what platform or any other area of life is that not true in?
Hi
thx for the article! Some comments:
“On paper something like “messy code” sounds horrible, but does a casual reader know what that means? More importantly, does she/he care?”
— but why do we care about ‘casual readers? i think the author was referring to people with “technical knowhow”, who are building something– not ‘casual readers’.
“Users really don’t care about anything related to code.”
— so you’re arguing that NO system in the world (not just WordPress) need be well-coded, because, as long as it gets the job done, users don’t care. Maybe that’s a legitimate position, but i think a lot of professionals would heartily disagree with that.
“Themes do mix presentation with logic, …undoubtedly a bad practice. However, …with some planning …you can write a logical and easy to follow theme.”
— this seems a resounding indictment, but you’re excusing it. I think it’s ok to say this is points against WordPress. Coders should not have to go out of their way to work around WP’s poor design.
“With the advent of the WordPress API all other criticisms go down the drain”
— at that point, if you’re not using the WP front-end, it’s pretty much not WordPress anymore. A database is a database.
My question is, why can’t a funded outfit like Automattic be bothered to do a proper rewrite? It’s a mature enough product at this point,
cheers!
If Automattic bothered to do a “proper rewrite” they would own the resulting program. It would no longer be open-source WordPress but a proprietary platform that was an offshoot of WordPress. It wouldn’t be WordPress anymore, it would be something else entirely.
A complete rewrite isn’t possible because no one has central control over what happens to WordPress.
What definition of “open source” means that “Automattic cannot modify WordPress”? Open Source means ANYONE can modify it– including Automattic.
I never said “Automattic cannot modify WordPress”. Sure they can submit modifications, but they don’t have the ability to complete a rewrite and force it on the WP community.
Automattic and WordPress.org are not one and the same. While there are ties and crossover between the folks who manage the different parts of the WordPress core and Automattic, Automattic doesn’t run the show at WordPress.org.
Take another piece of open-source software, let’s say Joomla! for instance. No single company or developer has the right or ability to completely rewrite Joomla and force the changes on the rest of the Joomla community. Same situation with Automattic and WordPress.
Heck, would you really want a private company like Automattic to completely rewrite an open-source piece of software used by millions of websites? That’d be like giving them permission to reach into the wallets of every WordPress website on the internet.
i have not coded on an open-source project, so i don’t know much about it.
but, if it’s allowed for anyone to submit a mod, then it’s not against open-source for automattic to submit lots of mods that fix whatever’s wrong with wp.
i never said automattic should “force” anything on anyone. is that even possible in open source projects?
your example of joomla doesn’t really add anything, you just switched the word “wordpress” for the word “joomla”.
You’re right, and lots of Automattic folks do contribute updates to the WP core.
As far as the wordpress/joomla deal goes, I just know some folks don’t really understand the difference between Automattic / WordPress.com / WordPress.org. You’re right again – it didn’t really add anything, I was just trying to clarify.
You are totally wrong Jon. As wordpress is released as I guess under GNU/GPLv2 licence, they have rights to do anything they want with code, and as they earn out of same code, they can decide whatever they want. And I don’t blame at all WP community, they are amazing, but more Automattic, because guys just don’t want to invest in WP, just to continue earning money and leave as is to community. Open Source doesn’t mean that you don’t have rights, it means that other people have rights to use it, see code and change it under SPECIFIC conditions. They have full rights to do versioning and decide whatever they want on their project, but if they make wrong move, they will make many Open Source programmers stop contributing if they do something bad. So no, that can only be an excuse. PHP is also Open Source and was just functional programming language, and compare v7 to v4 and you will see huge difference. I don’t know but I found it dissapointing immediately when I just downloaded and find out that “dolly” plugin is written like someone was playing from high school, not aligned, just bunch of code. Btw, I don’t say WP as WP is bad, just it’s design is awful, semantic is bad, spaghetti is small word for it. It is just a mess. For blog its amazing piece of software, but anything else… Nah
As long a it works, I’m delighted!
“You can argue that badly coded plugins can ruin WordPress’ speed and
safety but that’s like saying my Volvo wasn’t safe because I got injured
driving 180 miles an hour into a wall.” ARE YOU FOR REAL?!! Not even close. It’s like saying your Volvo wasn’t save because you installed ducttape seat belts on a recommendation and strapped jet engines to the outside for better speed.
The driving into wall thing is like saying a new stereo system caused this…
Hi, thanks, I was just looking a piece of pasta code and WordPress. Which themes would you recommend? I’m really new at coding, but I would like eventually open and tire apart my website and see how things are working and improve them :)
Yes they should rewrite the code base, but certainly not in OOP and stay way of the dated MVC approach for a less bloated source *cough* laravel
Often it is a spaghetti code.
I find the statement that WordPress is secure to be unjustified at best, and false at worst. There have been a number of high profile vulnerabilities in WordPress over the years, including implications in the Panama papers leak. The compatibility with PHP 5.2.4, a version now 12 years old and unsupported for the past 7 years is an active decision that increases the vulnerability of WordPress by not making full use of 7 years of security enhancements in the core libraries of PHP.
All of this is amplified by spaghetti code, which makes finding and patching problems a more time consuming, obtuse task.
For anyone with technical knowhow, WordPress ought to be bottom of the list of established solutions because these problems are organisational in nature and persist to this day (as of writing this WordPress is on version 4.9.2, two major revisions since the introduction of PHP 5.3), and will not be going away any time soon.
The problem with WordPress is that it’s seen by a lot studios as the one-stop-shop for all websites. In a perfect world, I would prefer it be completely coded from the ground up but the amount of work involved to change all the current WordPress websites would mean bye-bye to WordPress’s popularity so it’s never going to happen.
At the moment of writing this comment version 5 (beta) and the issue relating to the Gutenberg seems to be a deal breaker but I can’t imagine it being the case. Again people are concentrating on the frontend rather than what’s going on behind the scenes.
As for problems that come with WordPress they range from many (as we all know) purchased themes, plugins that are no longer supported, php 7 compatibility, security. These are the reasons why it should never be seen as the first and only option in the creation of a website.
Although WordPress serves a great purpose, the code is thankfully better than the old Joomla, this has been in development for 14 to 15 years. It’s a good platform for someone who clicks buttons and pays for everything — but what about developers?
Without developers nobody has anything. The total ignorance of this WordPress-like-cult is astounding. I have gone through the code over the years and I see next to no forward thinking. Remember, this is a decade and a half of development.
Schema design, why use a relational database if 99% of content is packed into a single table? How about renaming folders like wp-include? wp-settings.php will ruin your day — a simple if (defined …) constant check would solve that. It’s nice they let you rename the content folder. Prefixing everything with wp- is foolish and not necessary.
Considering it’s almost 2019 and the changes to WordPress have been so behind any PHP standards (An easy language, easy standards, PHPCS Lint anyone?) — It has to be one of the worst things to happen to the internet (Running so many sites on terror-ware).
Going back to the developers, of course Kinsta will defend this as it’s the pushed product. In space many years ago they used Thinkpads due to their reliable hardware and casing. NASA is not worried about click and pretty, this is example is silly. I am glad to see you ARE hosting your site on WordPress in which is advertised.
As “Developers” create these plugins, only disaster after disaster has happened over the years. One reason is they don’t know what they’re doing, another is WordPress is too stupid too enforce interfaces or abstract classes, or a REAL moderation system. User votes for danger-plugins is a BAD idea — Let the user find the error? Anti-every-development method.
Sadly, WordPress has a large marketshare because it’s all people know. I do think Gutenberg is cool, made with React, modern and functional. Perhaps they could do that with backend code, theming.
There is no way on Gods green earth Kinsta is going to pretend like the code doesn’t matter. “It just works”, until it doesn’t, the thermodynamics of code elusively creating code rot.
I must respectfully disagree with this article’s thrust. It’s not that the sentiments are perse wrong, as those who just deal with the frontend may not care about core code quality, but those of us tasked with truly developing solutions HAVE to deal with a package’s core code – and yes, it DOES matter to us.
I noticed a Joomla comment popped up, as it often does when speaking of WordPress for some reason, so let’s go there. It is now August 2019 and Joomla fully supports PHP 7 (it issues warnings when using PHP 5.3, and rightfully so). Also, version 4 is already around the corner. Yes, the migration (rather, evolution) from version 1.5 to the current 3.9 was a pain. Yes, I swore under my breath a LOT and looked to bail out. But in the long run, it was worth it, as the CMS is more secure, modern, and uses current versions of programming languages (though let’s not talk about Bootstrap… grrrr…). I have to write extensions for my projects, and, though I wish Joomla were less “heavy” on the MVC, overall my brain does not bleed when I do so – I focus more on my actual solution than fighting Joomla’s code. That’s the payoff for all the pain of evolving.
The point is that WordPress developers should have bitten the proverbial bullet long ago and did what was necessary to improve on its codebase. No excuses. As it stands, WordPress’ “framework” is (still) a hot mess – and again, yes, that does matter. Sooner or later it will be time to pay the piper for long-overdue updates. WordPress is truly a victim of its own success. I feel truly sorry for the millions of individuals and businesses who have built their respective web presences on this house of cards.
And one last bit – for goodness sakes, people, WordPress is STILL at its core a BLOG. Posts and pages, anyone? It is good for what it was born to do, but all this twisting of its purpose by overloading it with a ton of third-party plugins (some of which are dreadfully coded and downright insecure) is just wrong. There are other solutions out there. WordPress is simply a tool, and to automatically recommend it as a solution for all things web is flat-out lazy. Not accusing anyone specifically, it’s just something I’ve seen far too often.
Thank you! I’m a software developer with 20 years experience and I’ve just started to dip my toe into WordPress. And it is driving me crazy!! I’m itching to get my hands into the code and rewrite it all, but have to remind myself that the reason I’m using WordPress is to focus on content rather than the tech. Arghhhhh. Good to know that I’m not the only one finding it challenging to work with after being a ‘proper’ web developer.
To understand WordPress, we need to analyze it from its origins (release 2003?). The WordPress Core, still looks like early 2005 xD style. PHP has evolved a lot during the last 17 Years!
I think that one of the reason is HISTORICAL (almost like PYTHON). WordPress is actually build on PHP but not using OOP?
In my personal opinion it is a BUSINESS decision ! WordPress GOAL is not the Software Developers! WordPress is build since it ROOTS for NON PROFESSIONAL :)! Everyone who has a little UNDERSTANDING of HTML, JS, PHP is able to modify it.
This is why WordPress is so LOVED :).
PS. I personally use WordPress to explain to my friend what Spaghetti Code looks like and still owns the WEB :).
Take a look on DRUPAL? Build on top of Symfony, still noone eloves it. Only professionals use it :D.
WordPress is not user friendly. WordPress code is written horribly. I hope someone takes action and makes a better CMS.
People don’t care as long as the code works. But programmers care. Bad code makes other developer’s life miserable. For example with good code, you can create a plugin in 10 hours, with bad code it will take 4days (more or less). How much project gets bigger and bigger, code will get bad and bad, and the developer’s life miserable and more miserable.
If WordPress was coded properly, then the other theme and plugins will have a properly written code too.
WordPress is an old CMS. if something is old, it needs to get updated or get replaced.
Hello Babak, I disagree. WordPress wouldn’t power 38% of the web if it wasn’t user friendly. There are certainly areas where WordPress can improve, but in terms of user-friendliness, it’s one of the best options out there.
I’m a total non-coder, and use wordpress daily for multiple clients. My question… there is a lot of complaining, but no talk of a solution. Does this mean no solution exists?
Glad to hear that one programmer likes Gutenberg for the front-end. Does that mean the solution is almost half way “complete?”
Any chance that a similar effort on the backend could take place?
Lastly, what is the alternative? Is it Shopify? Wix? for ecom all the way?
I’d like to believe there is a solution all programmers and non-programmers like me would converge on, and say— “this is the best” but doubt that will ever happen.