Images

Professional WordPress Design and Development

Front cover of the book 'Professional WordPress'

Professional WordPress, Design and Development 2nd Edition : Brad Williams, David Damstra, Hal Stern; Wrox Programmer to Programmer, John Wiley & Sons, Canada, 2013, ISBN 978-1-118-44227-2

Working through this book chapter by chapter and making comments as I go. Starting with a completely ‘out the box’ installation, the plan is to implement all the tips and code in this book on this site and then take notes in this blog. My first impression is that this book is perfect for someone trying to pick up little gems. It is not the basics, and very quickly goes into detail, moving at a nice fast pace.

Chapter 1

A typical getting started section which introduces WordPress, how it started, how to host it, how to install it, writing your first post… anyone with any experience could happily skim this chapter.

Chapter 2

Once you’ve downloaded the latest release, take a look at the directory and file structure… Core files are contained in the wp-includes and wp-admin directories, wp-content contains customised files. Generally you should never modify core files for all the usual reasons.

wp-config.php

I found this particularly interesting as the advanced options are not usually covered in such detail. There are quite a few tips here that one could revisit later.
– You could, for security reasons move this file out of the WordPress directory and into the parent directory. WordPress looks for the file first in the WordPress root directory, then automatically in the parent directory if it doesn’t find it.
– Some options are stored as constants in WordPress, these are defined as follows: define( 'OPTION_NAME', 'value' ); for example: define('WP_DEBUG', false);
– To set secret keys go to http://api.wordpress.org/secret-key/1.1/salt/.
– Temporary development URL? set WP_SITEURL and WP_HOME
– Limit or disable post revisions – define( 'WP_POST_REVISIONS', false ); or define( 'WP_POST_REVISIONS', 5 );
– great debugging option is SAVEQUERIES, this saves all database queries into a global array that can be displayed on your page, great help when debugging :
define ( 'SAVEQUERIES', true );
To display the query in your theme add the following to any theme template file to view (note only if the logged in user has the ability to manage options:

if ( current_user_can( 'manage_options' ) ) {
  global $wpdb;
  print_r( $wpdb -> queries );
}
  • Enable logging
    • create a php_error.log file in your root WordPress directory
    • turn on log errors and point to your logging file:
    • this will also log any errors produced when turning on WP_DEBUG
@ini_set( 'log_errors';, 'On'; );
@ini_set( 'display_errors', 'Off')';
@ini_set('error_log', '//public_html/cms/php_error.log' );