WordPress Coding Conventions

I plan on using the best practices that I know, including the ones laid out in the WordPress Codex.3 This means that I will do my best to write correct markup, name variables properly, create constants when necessary, and include thorough, clear comments within all of my programming.

I will also take on the following convention for printing code as used in previous WordPress books published by Rockable. This means that all lines of code will appear against a light grey background in a fixed-width typeface, like this:

<?php echo 'Hello World!'; ?>

Sometimes a line of code is too long to fit entirely on one line. In this case, the grey background of the following line (or lines, for a really long line) will be slightly indented. In most cases, a space character is permissable between the last character on the initial line and the first character on the next line. If a space is not allowed, there will be a continuation marker ( ▶ ) to remind you. For example, here a space is permitted between.

<?php echo 'The quick brown fox jumped over the lazy dog.'

But in the following code, there is no space intended after the underscore. Therefore “pingback_url” is correct:

<link rel="pingback" href="<?php bloginfo('pingback_ ▶
url'); ?>" />

You may also like...