Hacker News new | ask | show | jobs
by raziel2p 4044 days ago
> Apart from that, you can write your own beautiful code according to the newest PHP standards if you want in your WordPress-powered projects.

You really can't. Wordpress actively prevents you from writing beautiful, modern code. When writing themes, every template has to be in the root directory of the theme, creating an awful mess. All of wordpress has global variables and/or state in functions that is simply inescapable, making it impossible to write unit tests. Dependency injection is completely out of the question.

If you want to modify some behaviour and someone hasn't thought of putting in a filter for the exact thing you want to modify, it's not a matter of extending a class and overriding a method. Because wordpress is littered with huge god functions with global state, you basically have to copy/paste hundreds of lines of code and make sure that you keep that up-to-date with core updates yourself to prevent future bugs.

Several times I've gone into plugin development thinking "this must be possible without making too much of a mess", thinking I can separate out the unit-testable bits and write a thin WP wrapping layer that deals with the global state. Every time I've been disappointed.

It's not about PHP versions alone. It's that Wordpress was designed in and for PHP 4, and was never modernized. That's an inescapable fact, regardless of which PHP version your server runs.