Here are the areas I've been cleaning up, and my recommendations for Hotaru CMS Coding Guidelines:
Function comments
I'm not eactly sure of the rules, but I've been doing something like this:
PHP Code:
/**
* Generate either default or friendly urls
*
* @param array $parameters an array of pairs, e.g. 'page' => 'about'
* @param string $head either 'index' or 'admin'
* @return string
*/
Curly braces
Every conditional statement should have braces. For functions, I've been putting the opening brace on the next line, but not for control structures (if, while, foreach, etc.) unless helpful for readability, e.g.
PHP Code:
function url($parameters = array(), $head = 'index')
{
Control Structures
I've been putting a space between if, while, foreach, etc. and the opening bracket. This keeps the code clean and distinguishes conditionals from function calls, e.g.
PHP Code:
if ($head == 'index') {
$url = baseurl . 'index.php?';
}
Globals
I've been putting a blank line after global declarations, e.g:
PHP Code:
function url($parameters = array(), $head = 'index')
{
global $post;
if (friendly_urls == "false") {
Constants
I've capitalized all constants, e.g.
PHP Code:
if (FRIENDLY_URLS == "false") {
if ($head == 'index') {
$url = BASEURL . 'index.php?';
}
PHP in HTML
When using PHP in HTML, I've used semi-colons after every statement, e.g.
PHP Code:
<a href="<?php echo BASEURL; ?>"><?php echo $lang["example_home"]; ?></a>
Bookmarks