Fix code style errors found by PHPCS

* remove trailing whitespace
* adjust functions / parameters to conform to WordPress style
* no more inline if statements
* added some escaping and sanitizing
* added commas to end of arrays