Instead of reading any of this why not just let the computer nag you? From the Pressbooks plugin directory:
Bonus: You can sometimes automatically fix errors by running:
vendor/bin/phpcbf --standard=phpcs.ruleset.xml /path/to/your/file
npm run lint.
We enforce Human Made Coding Standards with the following small tweaks.
camelCasefor class methods & properties,
UPPERCASEfor class constants,
- PHP Sessions are allowed.
PHP Namespaces have been available since 2009. Namespaces are not a new concept. We use them.
Our namespace is:
- If your Class isn’t an Object like
WP_Queryetc., write a library of functions.
- If your Class is a bunch of Static methods and nothing else, write a library of functions.
- Afraid of function name collisions? See Namespaces.
Write accurate PHPDoc styled code comments.
Prefix action and filter hook names with
Prefix WP Post meta keys with
Prefix WP User meta keys with
Prefix WP Option names with
Theme files are exempt from the above rules, but should still make an effort to follow them.