This page covers design patterns as utilized in WordPress. For a more general look at design patterns see the sibling article over on BabyProgrammer.
Any patterns which are unique to WordPress (or primarily utilized within WP and not the wider ecosystem) will be noted as such.
- Tom McFarlin. Considerations for Design Patterns for WordPress. 2019.
- An introductory article on WP specific design patterns.
- Josh Pollock. Basic PHP Design Patterns for WordPress Developers. torque, 2016.
- Compares and contrasts event driven and model view controller architectures.
- Covers the Singleton Pattern which is very common in WP plugin development, including the use of sub-classes.
- Covers the Factory Pattern, which is not commonly used in WP.
- Covers the usage of globals by WP Core.
Individual Patterns
- Chain of Responsibility Pattern
- Carl Alexander. Using the Chain-of-Responsibility Pattern to Hash WordPress Passwords. 2020.
- Decorator Pattern
- Carl Alexander. Helping WordPress Make Friends with the Decorator Pattern. 2014.
- Dependency Injection Pattern
- Josh Pollock. Designing Better WordPress Database Abstractions Using Dependency Injection. torque, 2016.
- Carl Alexander. Using Dependency Injection with WordPress. 2017.
- Carl Alexander. Dependency Inversion Principle and WordPress. 2017.
- Front Controller Pattern
- David Hayes. WordPress and the Front Controller Design Pattern. wpshout, 2014.
- Mediator Pattern
- Carl Alexander. The Mediator Pattern in WordPress. 2014.
- Model View Controller Pattern
- Carl Alexander. Thoughts on WordPress and the MVC Pattern. 2015.
- Repository Pattern
- Tom McFarlin. A General Example of the Repository Pattern in WordPress. 2019.
- Josh Pollock. Implementing the Repository Pattern in WordPress. torque, 2017.
- Singleton Pattern
- Josh Pollock. Singletons in WordPress: Good or Evil? torque, 2016.
- Strategy Pattern
- Carl Alexander. Importing Data into WordPress Using the Strategy Pattern. 2016.