Coding Standards

Validating with PHP Code Sniffer

Instead of reading this why not just let the computer nag you? From the Pressbooks plugin directory:

  1. composer install
  2. composer standards

Bonus: You can sometimes automatically fix errors by running:

composer fix or vendor/bin/phpcbf --standard=phpcs.ruleset.xml /path/to/your/file

Pressbooks Coding Standards (Mandatory)

We enforce Human Made Coding Standards with the following small tweaks.

Write Classes or Namespaced functions, stay out of global space!

We use PHP Namespaces. Our namespace is: \Pressbooks\

Pressbooks Coding Recommendations (Optional)

Write accurate PHPDoc styled code comments.

Prefix action and filter hook names with pb_.

Prefix WP Post meta keys with pb_.

Prefix WP User meta keys with pb_.

Prefix WP Option names with pressbooks_.

Theme files are exempt from the above rules, but should still make an effort to follow them.