Download - Breaking up (your code) is hard to do
@alleydev
Alley Interactive
● We are a full-service digital agency● WordPress.com VIP partner● Hiring!
@alleydev
The Problem
Navigating WordPress’ code base is difficult
Code organization is one large pain point that WordPress has, because it is not regulated
@alleydev
The Problem: continued
Developers not thinking in an OOP mind set.If this doesn’t resonate with you…
Developers not thinking ahead to what can be reused
This leads to too much logic being included in top level (core hierarchy) template files
@alleydev
The Problem: continued
Many developers start coding after finding WordPress and learn from tutorials that, while technically correct, are actually bad practice
@alleydev
Benefits of a Standard Structure
● Frontend developers benefit
● Onboarding / collaboration
● Better Code, Period
@alleydev
Theme Structure● theme-name
○ inc/
■ post-types/
■ helpers.php
○ static/
■ css/
■ js/
○ template-parts/
○ index.php
○ single.php
○ etc...
@alleydev
AbstractingCodeTechnically works, could be optimizedlook for common patterns(source: un-named online tutorial)
What if we use this in 5 places throughout our site?
@alleydev
TemplatePartsThe reusable output
You can now change this HTML All in one place.
Template parts should include output functions, not display logic
@alleydev
Abstracting WP_Query
1. In functions.php2. Or better yet in
inc/helpers.php3. Now able to reuse
the same logic with one function call
@alleydev
Consider the following
First step towards OOP is becoming more DRY with your codeRemember, “If you write it twice” … “you’ve written too much”This will make you a better developer
@alleydev
Resources to learn
● My articles on http://addactiondan.me
○ http://bit.ly/1JulWGr
● Design Patterns in WordPress: The Singleton Pattern
○ by Tom McFarlin
■ http://bit.ly/1G80cA0
● Fieldmanager Code Base
○ by Alley Interactive
■ http://bit.ly/1iALI6r
@alleydev
Interested in Working at Alley?● We’re hiring!
● If you’re interested, please send your resume & code samples to [email protected]
● More info here:○ http://www.alleyinteractive.com/hiring/