Layered architecture in WordPress: get logic out of functions.php
Fourteen years of WordPress work, one recurring problem: everything ends up in functions.php. Here are the five layers I use to separate hooks, workflows, business rules, database access and outside services, plus a before-and-after AJAX handler.