Presentations
Templates
Features
Teams
Pricing
Log in
Sign up
Log in
Sign up
Menu
Best Practices
by
curtismchale
WordPress Coding Standards
If in doubt space it out
No one line conditionals
Find them all here
One line Conditional Example
BAD BAD BAD
Fixed
YODA Conditions
Don't be Smart
Readability is more important than clever code
Future you is not as smart as coffee fuelled current you
Other Best Practices
Single Responsibility
A function should do 1 thing
Example
So what if we wanted to let people that can see holes download something as well?
Always GET and show
Look at WordPress Core
get_the_title()
the_title()
Shortcodes need data returned
Example
Write a PHP Docblock First
Yup before you write code write down what it's going to do
Example
My first stop in understanding a new project is to write docs for every function
See the Codex
Inline Explanations
If you need more than a docblock then you're likely being clever
Example
No Closing ?>
Best Practices
By curtismchale
Made with Slides.com
Best Practices
Some best practices for coding with WordPress, and coding in general.
1,757
curtismchale
curtismchale
More from
curtismchale