WordPress Coding Standards for Uniform and Beautiful development

WordPress itself has a good guide but I have summarized it for my own use. Here is a list of *half finished* blog post about WordPress coding standards.

WordPress PHP Coding Standards

General:

  • use real tabs equivalent to 4 spaces.
  • Do not use closing PHP tags.
  • Starting braces should be at the end of the line whereas ending braces should be at new line with previous intent.
  • never use shorthand php tags.
  • use spaces appropriately.

Variables:

  • Variable names should be all lowercase, words separated with underscores

Classes:

  • Class names should use capitalized words separated by underscores.
  • Any acronyms should be all uppercase.

e.g.
class Local_File_Operations {}
class HTTP_Request {}

Constants:

Constants should be all uppercase, separated by underscores

define( 'DOING_AJAX', true );

File Names:

File names should be all lower case, separated with dashes

my-plugin-name.php

NOTE: I wrote this post for my own uses but it might be useful for you also. If you have any suggestion please leave a comment be below.

Speak Your Mind

*