The WordPress open-source project is now 20 years old. In that time, PHP and JavaScript have changed a lot. There is still some old code from back then running and it works. That’s great, but if you’re writing PHP and JavaScript for WordPress now, we can do better.
Using dependency injection in PHP.
In this 5 part ebook, I walk through different ways you can structure, refactor and test the PHP code you write for WordPress plugins using dependency injection.
This Book will take about an hour to read. It’s all based on real code I’ve written and includes Github links whenever possible. This isn’t a book that teaches you how to make a plugin from scratch — not something I get paid do do often. It’s about improving or fixing existing plugins, which are the most common tasks for WordPress plugin developers.
Less Foo, No Bar
I am not covering how to build a todo app as a WordPress plugin from scratch. This is about how to improve plugins that already exist.
This book is based on stuff I’m working on, all the code examples are copied from actual work I did. As much as possible, I linked to pull requests where you can see where I implemented these patterns.
Josh has taken a complex topic and broken it down in such an accessible way, that I doubt any developer of any level would get to the end of the book and not understand what’s going on. His use of real-world examples of code he’s written for production helps the reader follow the process: from quickly hacking together some code to solve a problem, to refactoring it for prime time.
What makes Josh’s writing stand out from most other technical books is his friendly style of writing, how effortlessly he makes complex topics easy to understand, and the little bits of humor and photography from his personal life sprinkled throughout the book.
❞
Jonathan Bossenger
WordPress Developer Educator at Automattic
Standard
$30
One copy of eBook
Site Membership
$120/year
eBook
Request code samples
Early Access
Josh is the author of about a bajillion WordPress development tutorials, two now three books, about WordPress development, and is a contributor to WordPress core and many popular plugins.
What Is In The Book
- How to remove singletons
- Code examples based on plugins I’m working on now. Often with links to pull requests.
- How to write tests with phpunit for WordPress plugins
- How to make your plugins easier to extend by third-party developers
- Pictures of my dog, also flowers.
Also, it’s not very long. You can probably read this in an hour or so.
By A Guy With ADD For Folks With A Lot Going On
Who has time for a 4-inch thick book or a 25-hour course? I don’t. Maybe beginners do — but this isn’t an intro — it assumes you know object-oriented PHP. This should take an hour or two to read.
Parts
Singletons & Dependency Injection In WordPress
Refactoring A WordPress Plugin To Use A Container
Refactoring A Class To Make It Reusable Using Dependency Injection
Testing WordPress Hooks
Using “Action” Classes In WordPress Plugins To Encapsulate Logic
Separating Concerns And Decoupling
Frequently Asked Questions
How Can I Download The Latest Version?
If you have already published the book, go to https://app.lemonsqueezy.com/my-orders and log in with the same email address you can download the latest version.
What Formats Is The Book Available In?
Currently, it is a PDF. Members can also read the book online, and leave comments. ePub format is planned, but I can’t get it right yet.
Can I Read This On A Kindle?
Yes, you can send the PDF to your Kindle. This page describes how to send a PDF or ePub to your Kindle https://www.amazon.com/sendtokindle/email