This repository contains code examples for the talk "Who Needs Code Quality Anyway? A WordPress Perspective" - demonstrating common bad practices in WordPress development and their improved alternatives.
Think you don't need coding standards, documentation, or tests? Perfect! In this tongue-in-cheek session, I'll show you why you're right… and then why you're absolutely, hilariously wrong.
We'll dive into what PHP 7 & 8 offer, examine how design patterns and best practices affect WordPress projects, and look at the real-world impact of skipping (or following) good coding habits.
Expect surprises, laughs, and practical insights to take your code from "barely works" to "built to last." You might just leave loving code quality after all.
- Get familiar with modern PHP features in a WordPress context
- Understand the business case for (and against!) coding standards
- Learn how small changes in code quality pay off in big ways
Christoph Daum is a WordPress and PHP specialist, with over 25 years of experience in web development. He started first web projects in the late 90s, some of which are still leading in their field. As technical lead on multiple projects with millions page impressions per month, his responsibilities included theme and plugin development, performance optimizations, and feature planning. Christoph is a contributor to the WordPress ecosystem, host and founder of his local WordPress Meetup in Dortmund, and a frequent speaker at meetups and WordCamps.
- Event: WordCamp Netherlands 2025
- Date: November 27-28, 2025
- Location: Den Haag, The Netherlands
- Talk Date & Time: November 27, 2025 at 14:45 (Track 2)
- Session Details: View on WordCamp.org
- Slides: Coming soon
- Recording: Will be available on WordPress.tv
This repository contains a series of examples, of which each demonstrates a specific issues, not all will be covered in the talk due to time limitations. The examples are grouped into the following categories:
Essential practices for maintainable code
- Clever Coding vs Readable - Readable code vs. overly clever solutions
- Magic Numbers - Using magic numbers vs. named constants
- Early Returns - Guard clauses and early returns
- Function Length - Function length and complexity
- Boolean Parameters - Boolean parameters vs. explicit methods
- String Concatenation - String concatenation vs. sprintf/printf (with i18n focus)
- Return Type Consistency - Consistent return types
- Coding Standards - Following WordPress Coding Standards
- DRY & YAGNI & KISS - DRY (Don't Repeat Yourself), YAGNI, and KISS principles
- Commented Code - Commented out code without explanation
- Environment-Dependent Code - Environment-dependent code behavior
- Arrays vs Classes - Using associative arrays vs. custom classes
- Anti-Patterns - Common OOP anti-patterns and better alternatives
Foundation concepts for modern WordPress development
- Type Hints - Type hints and type declarations
- Strict Types vs Mixed - Strict types vs. mixed types
- Modern PHP Features - Modern PHP features (null coalescing, arrow functions, etc.)
Designing scalable and maintainable systems
- Dependency Injection - Dependency injection vs. global state
- God Objects - God objects and single responsibility
- Business Logic vs Presentation - Separating business logic from presentation
Graceful failure and debugging strategies
- Error Handling - Proper error handling techniques
- Error Suppression - Error suppression with @ operator
- Error Messages - Error message quality
- Error Logging - Error logging practices
Protecting your WordPress applications
- SQL Injection - SQL injection prevention
- Nonce Validation - Nonce validation for CSRF protection
- Sanitization & Escaping - Input sanitization and output escaping
- Capability Checks - User capability verification
- External Data Validation - Validation of external data
Communicating through code and comments
- PHPDoc Documentation - PHPDoc documentation best practices
- Unprofessional Comments - Professional vs. unprofessional comments
- Semantic Versioning - Proper use of semantic versioning (MAJOR.MINOR.PATCH)
Each example folder contains:
bad.php- Demonstrates the bad practicegood.php- Shows the improved approachREADME.md- Explanation of the issue and solution
Some examples also include:
bad-real.php/better-real.php- Real-world examples from WordPress coreOVERVIEW.md- Additional overview or context
These examples are designed for educational purposes, demonstrating common pitfalls in WordPress development and how to avoid them.
None of the code examples in this repository are meant to be used as-is in production environments. They are simplified snippets to illustrate specific points about code quality and best practices. None of the examples have been tested for security, performance, or compatibility. Always review and adapt code to fit your specific project requirements and standards.
For educational purposes multiple classes are used in the same file, which is not a recommended practice for production code and is only done to keep the examples compact and easy to follow.
The examples have been created for educational purposes with the help of Claude Sonnet 4.5 and been reviewed manually.
Contributions are welcome! If you have suggestions for additional examples or improvements to existing ones, please open an issue or submit a pull request.
This project is licensed under the GNU General Public License v2.0 - the same license as WordPress itself.