Hi folks! I was wondering what was the general consensus (or if there is one at all) regarding code style for WordPress themes and plugins. This is a question for both fellow developers and customers. The way I see it now, there are two options (note that these are just my personal opinions):
1. The WordPress guidelines:
https://make.wordpress.org/core/handbook/coding-standards/php/
Pros:
- Plugin and theme code will use the same style as with the WordPress core. so there will be more consistency.
- A bit outdated. Not used by any other modern projects or frameworks.
- Lots of spaces everywhere. Hard to apply without a code-formatter (I'm using PhpStorm).
2. The PHP-FIG PSR-x guidelines:
http://www.php-fig.org/psr/psr-1/ (there are also PSR-0, PSR-2, PSR-3, and PSR-4)
Pros:
- A more modern approach.
- Used by newer frameworks like Symfony2, Laravel, etc.
- Voting members from lots of big projects: http://www.php-fig.org/#voting-members
Cons:
- Very much different from the WordPress guidelines.
So, what’s your opinion on this? Do you prefer the WordPress or the PSR-x style? Or something else?
Cheers,
Liviu