Use WordPress standards formatting

Mostly spacing and indentation. Also adds curly braces to if statements as per standards.
http://make.wordpress.org/core/handbook/coding-standards/php/#brace-style